結果
| 問題 | No.1862 Copy and Paste |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-03-04 22:04:13 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 887 bytes |
| 記録 | |
| コンパイル時間 | 2,114 ms |
| コンパイル使用メモリ | 210,268 KB |
| 最終ジャッジ日時 | 2025-01-28 05:21:50 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 24 TLE * 3 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
int main(){
cin.tie(0);
ios::sync_with_stdio(0);
using ll = long long;
ll A,B,N; cin >> A >> B >> N;
using P = tuple<ll,int,int>;
priority_queue<P,vector<P>,greater<P>> q;
q.push({0LL, 1, 0});
map<pair<int,int>,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;
}