結果

問題 No.1862 Copy and Paste
ユーザー rogi52rogi52
提出日時 2022-03-04 22:16:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,107 bytes
コンパイル時間 3,245 ms
コンパイル使用メモリ 227,800 KB
実行使用メモリ 383,772 KB
最終ジャッジ日時 2023-09-26 01:21:14
合計ジャッジ時間 9,687 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,752 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 12 ms
4,416 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 118 ms
13,008 KB
testcase_10 AC 18 ms
5,728 KB
testcase_11 AC 9 ms
4,552 KB
testcase_12 AC 52 ms
8,420 KB
testcase_13 AC 46 ms
7,964 KB
testcase_14 AC 5 ms
4,380 KB
testcase_15 AC 81 ms
9,932 KB
testcase_16 AC 570 ms
30,496 KB
testcase_17 AC 46 ms
7,964 KB
testcase_18 AC 21 ms
5,496 KB
testcase_19 AC 9 ms
4,380 KB
testcase_20 AC 47 ms
8,024 KB
testcase_21 AC 691 ms
43,076 KB
testcase_22 AC 55 ms
8,660 KB
testcase_23 AC 49 ms
8,084 KB
testcase_24 AC 70 ms
9,960 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 72 ms
10,060 KB
testcase_27 AC 9 ms
4,444 KB
testcase_28 TLE -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#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