結果

問題 No.1449 新プロランド
ユーザー shiomusubi496shiomusubi496
提出日時 2021-03-31 00:11:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 934 bytes
コンパイル時間 1,747 ms
コンパイル使用メモリ 181,512 KB
実行使用メモリ 5,132 KB
最終ジャッジ日時 2023-08-25 16:44:54
合計ジャッジ時間 2,954 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 6 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 1 ms
4,388 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 7 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 26 ms
5,132 KB
testcase_28 AC 4 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:25:13: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   25 |         auto[c,v,p]=PQ.top();PQ.pop();
      |             ^

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using A=array<ll,3>;
constexpr ll INF=1e18;
struct edge{
    int to;
    ll cost;
};
bool chmin(ll&a,ll b){return a>b?a=b,true:false;}
vector<edge>G[105];
map<ll,ll>dist[105];
ll T[105];
int main(){
    int N,M; cin>>N>>M;
    for(int i=0;i<M;i++){
        int A,B,C; cin>>A>>B>>C;
        G[A-1].push_back({B-1,C});
        G[B-1].push_back({A-1,C});
    }
    for(int i=0;i<N;i++) cin>>T[i];
    priority_queue<A,vector<A>,greater<A>>PQ; PQ.push({0,0,0});
    dist[0][0]=0;
    while(!PQ.empty()){
        auto[c,v,p]=PQ.top();PQ.pop();
        if(v==N-1){
            cout<<c<<endl;
            return 0;
        }
        if(dist[v][p]<c) continue;
        c+=T[v];p=min(p+T[v],1001ll);
        for(edge e:G[v]){
            if(dist[e.to].count(p)==0)dist[e.to][p]=INF;
            if(chmin(dist[e.to][p],c+e.cost/p)) PQ.push({c+e.cost/p,e.to,p});
        }
    }
}
0