結果

問題 No.1862 Copy and Paste
ユーザー rogi52rogi52
提出日時 2022-03-04 21:57:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 877 bytes
コンパイル時間 2,413 ms
コンパイル使用メモリ 217,340 KB
実行使用メモリ 239,800 KB
最終ジャッジ日時 2023-09-26 00:54:47
合計ジャッジ時間 11,189 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
11,468 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 26 ms
5,388 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 299 ms
17,044 KB
testcase_10 AC 42 ms
6,080 KB
testcase_11 AC 18 ms
4,792 KB
testcase_12 AC 141 ms
10,736 KB
testcase_13 AC 125 ms
9,704 KB
testcase_14 AC 9 ms
4,376 KB
testcase_15 AC 215 ms
14,224 KB
testcase_16 AC 1,154 ms
46,320 KB
testcase_17 AC 125 ms
9,964 KB
testcase_18 AC 48 ms
6,576 KB
testcase_19 AC 18 ms
4,788 KB
testcase_20 AC 116 ms
9,824 KB
testcase_21 AC 1,222 ms
49,096 KB
testcase_22 AC 157 ms
11,356 KB
testcase_23 AC 152 ms
10,696 KB
testcase_24 AC 187 ms
14,056 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 189 ms
13,832 KB
testcase_27 AC 19 ms
4,732 KB
testcase_28 TLE -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);

    ll A,B,N; cin >> A >> B >> N;
    using P = tuple<ll,ll,ll>;
    priority_queue<P,vector<P>,greater<P>> q;
    q.push({0, 1, 0});
    map<pair<ll,ll>,ll> mp;
    mp[{1, 0}] = 0;
    ll ans = -1;
    while(!q.empty()) {
        auto [dist, s, t] = q.top(); q.pop();
        if(dist != mp[{s, t}]) continue;

        if(s >= N) {
            ans = dist; break;
        }

        if(!mp.count({s, s}) || mp[{s, s}] > dist + A) {
            mp[{s, s}] = dist + A;
            q.push({dist + A, s, s});
        }

        if(!mp.count({s + t, t}) || mp[{s + t, t}] > dist + B) {
            mp[{s + t, t}] = dist + B;
            q.push({dist + B, s + t, t});
        }
    }

    cout << ans << endl;
}
0