結果

問題 No.1862 Copy and Paste
ユーザー rogi52rogi52
提出日時 2022-03-04 22:14:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,016 bytes
コンパイル時間 2,697 ms
コンパイル使用メモリ 212,416 KB
実行使用メモリ 259,428 KB
最終ジャッジ日時 2023-09-26 01:19:05
合計ジャッジ時間 9,044 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,760 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 12 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 147 ms
12,852 KB
testcase_10 AC 20 ms
5,704 KB
testcase_11 AC 9 ms
4,404 KB
testcase_12 AC 60 ms
8,384 KB
testcase_13 AC 48 ms
7,832 KB
testcase_14 AC 5 ms
4,376 KB
testcase_15 AC 93 ms
9,932 KB
testcase_16 AC 668 ms
30,756 KB
testcase_17 AC 53 ms
7,936 KB
testcase_18 AC 22 ms
5,468 KB
testcase_19 AC 10 ms
4,376 KB
testcase_20 AC 51 ms
7,780 KB
testcase_21 AC 803 ms
43,004 KB
testcase_22 AC 64 ms
8,612 KB
testcase_23 AC 56 ms
8,020 KB
testcase_24 AC 89 ms
9,908 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 85 ms
10,028 KB
testcase_27 AC 10 ms
4,436 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;
using ll = long long;
const ll C = numeric_limits<int>::max();

inline ll f(int s, int t){ return s * C + t; }

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

    using ll = long long;
    ll A,B,N; cin >> A >> B >> N;
    using P = pair<ll,ll>;
    priority_queue<P,vector<P>,greater<P>> q;
    q.push({0LL, f(1, 0)});
    unordered_map<ll,ll> mp;
    mp[f(1, 0)] = 0;
    while(!q.empty()) {
        auto [dist, p] = q.top(); q.pop();
        int s = (int)(p / C), t = p % C;
        if(dist != mp[f(s, t)]) continue;

        if(s >= N) {
            cout << dist << endl; return 0;
        }

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

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