結果

問題 No.2099 [Cherry Alpha B] Time Machine
ユーザー nyyanyya
提出日時 2022-12-23 23:10:29
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,182 bytes
コンパイル時間 4,163 ms
コンパイル使用メモリ 242,132 KB
実行使用メモリ 439,544 KB
最終ジャッジ日時 2024-11-18 04:43:28
合計ジャッジ時間 181,194 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14 TLE * 58
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:30:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   30 |         auto [cost,now]=q.top();
      |              ^

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i=0;i<(n);i++)
#define per(i,n) for(int i=(n)-1;i>=0;i--)
#define all(x) x.begin(),x.end()
typedef long long ll;
//using mint = modint;
using mint = modint998244353;
//using mint = modint1000000007;
using P = pair<int, int>;

const ll INF=1LL<<60, dx[]={0,1,0,-1},dy[]={1,0,-1,0};
template <typename T> inline bool chmin(T& a,const T&b) {if(a>b){a=b; return 1;} return 0;}
template <typename T> inline bool chmax(T& a,const T&b) {if(a<b){a=b; return 1;} return 0;}

int main(){

    ll T,X,A,Y,B;
    cin >> T;
    cin >> X >> A;
    cin >> Y >> B;
    
    map<ll,ll> mp;
    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>, greater<pair<ll,ll>>> q;
    q.push({1ll,0ll});

    while(!mp[T]) {
        auto [cost,now]=q.top();
        q.pop();

        //cout << "##" << cost << " " << now << endl;
        if(!mp[now]) {
            mp[now]=cost;
            if(!mp[now+1]) q.push({cost+1,now+1});
            if(!mp[now+A]) q.push({cost+X,now+A});
            if(!mp[now-B]) q.push({cost+Y,now-B});
        }
    }
    cout << mp[T]-1 << endl;

    return 0;

}
0