結果
問題 | No.3013 ハチマキ買い星人 |
ユーザー |
|
提出日時 | 2025-01-25 12:52:33 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,704 bytes |
コンパイル時間 | 3,343 ms |
コンパイル使用メモリ | 283,700 KB |
実行使用メモリ | 22,500 KB |
最終ジャッジ日時 | 2025-01-25 22:25:10 |
合計ジャッジ時間 | 14,626 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 11 WA * 34 |
ソースコード
#include <bits/stdc++.h>// #include <atcoder/all>using namespace std;// using namespace atcoder;#define rep(i, a, n) for(int i = a; i < n; i++)#define rrep(i, a, n) for(int i = a; i >= n; i--)#define inr(l, x, r) (l <= x && x < r)#define ll long long#define ld long double// using mint = modint1000000007;// using mint = modint998244353;constexpr int IINF = 1001001001;constexpr ll INF = 1e18;template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}vector<ll> dijk(int s, vector<vector<pair<ll, ll>>> &g){priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> que;vector<ll> dist(g.size(), (1LL<<60));que.push(make_pair(0, s));dist[s] = 0;while(!que.empty()){pair<ll, ll> q = que.top(); que.pop();ll d = q.first, u = q.second;if(dist[u] < d) continue;for(auto nq: g[u]){ll v = nq.first, cost = nq.second;if(dist[v] > d+cost){dist[v] = d+cost;que.push({dist[v], v});}}}return dist;}int main(){ll n, m, p, y; cin >> n >> m >> p >> y;vector<vector<pair<ll, ll>>> g(n);rep(i, 0, m){int a, b, c; cin >> a >> b >> c;a--, b--;g[a].push_back({b, c});g[b].push_back({a, c});}vector<ll> price(n, IINF);rep(i, 0, p){int d, e; cin >> d >> e;d--;chmin(price[d], e);}vector<ll> dist = dijk(0, g);int ans = 0;rep(i, 0, n){if(y-dist[i] < 0) continue;chmax(ans, (y-dist[i])/price[i]);}cout << ans << endl;return 0;}