結果
問題 | No.3013 ハチマキ買い星人 |
ユーザー |
![]() |
提出日時 | 2025-02-01 17:34:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 521 ms / 2,000 ms |
コード長 | 1,634 bytes |
コンパイル時間 | 5,713 ms |
コンパイル使用メモリ | 225,256 KB |
実行使用メモリ | 20,928 KB |
最終ジャッジ日時 | 2025-02-01 17:34:52 |
合計ジャッジ時間 | 20,057 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 45 |
ソースコード
#ifndef ONLINE_JUDGE#define _GLIBCXX_DEBUG#endif#include <bits/stdc++.h>#include <atcoder/all>using namespace atcoder;using namespace std;#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)#define ll long long#define bigmod 1000000007#define P pair<ll,ll>#define T tuple<ll,ll,ll>#define nall(a) a.begin(),a.end()#define rall(a) a.rbegin(),a.rend()//逆順ソート#define inf 2000000000000000000LL#define mint modint998244353#define mkp make_pair#define mkt make_tupletemplate<class X> using priority_minq = priority_queue<X, vector<X>, greater<X>>;//小さい順ll min(ll a1,ll b1){if(a1>b1)return b1;else return a1;}ll max(ll a1,ll b1){if(a1>b1)return a1;else return b1;}#define chmax(x,y) x = max(x,y)#define chmin(x,y) x = min(x,y)//cout << fixed << setprecision(10); double型出力するときに使うやつll n,m,p,y;vector<P> g[200009];//to,costll dat[200009];int main(){cin >> n >> m >> p >> y;rep(i,m){ll a,b,c; cin >> a >> b >> c;g[a].push_back(mkp(b,c));g[b].push_back(mkp(a,c));}rep(i,n)dat[i+1] = 0;dat[1] = y;priority_queue<P> qu; qu.push(mkp(y,1));while(!qu.empty()){ll to,cost; tie(cost,to) = qu.top();qu.pop();if(cost < dat[to])continue;for(auto nex : g[to]){if(dat[nex.first] < cost - nex.second){dat[nex.first] = cost - nex.second;qu.push(mkp(dat[nex.first],nex.first));}}}ll ans = 0;rep(i,p){ll pos,cost; cin >> pos >> cost;chmax(ans,dat[pos]/cost);}cout << ans << endl;}