結果
問題 |
No.3013 ハチマキ買い星人
|
ユーザー |
|
提出日時 | 2025-01-25 15:01:41 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 409 ms / 2,000 ms |
コード長 | 771 bytes |
コンパイル時間 | 987 ms |
コンパイル使用メモリ | 76,212 KB |
実行使用メモリ | 20,808 KB |
最終ジャッジ日時 | 2025-01-25 23:39:07 |
合計ジャッジ時間 | 12,009 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 45 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:26:22: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions] 26 | auto [x,v]=pq.top(); | ^ main.cpp:29:26: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions] 29 | for(auto [to,cost]:G[v]){ | ^
ソースコード
#include<iostream> #include<vector> #include<queue> using namespace std; #define rep(i,n) for(int i=0;i<(n);++i) using pl=pair<long,long>; const long INF=3e18+100; int main(){ int N,M,P; long Y; cin>>N>>M>>P>>Y; vector<vector<pl>>G(N); rep(i,M){ int a,b,c; cin>>a>>b>>c; a--;b--; G[a].push_back(make_pair(b,c)); G[b].push_back(make_pair(a,c)); } vector<long> d(N,INF); priority_queue<pl,vector<pl>,greater<pl>> pq; pq.push(make_pair(0,0)); d[0]=0; while(!pq.empty()){ auto [x,v]=pq.top(); pq.pop(); if(x>d[v]) continue; for(auto [to,cost]:G[v]){ if(d[to]<=x+cost) continue; d[to]=x+cost; pq.push(make_pair(d[to],to)); } } long ans=0; rep(i,P){ long D,E; cin>>D>>E; D--; ans=max(ans, (Y-d[D])/E); } cout<<ans<<endl; }