結果
| 問題 |
No.3013 ハチマキ買い星人
|
| ユーザー |
it_is_a_pity_
|
| 提出日時 | 2025-01-25 20:16:18 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,454 bytes |
| コンパイル時間 | 3,310 ms |
| コンパイル使用メモリ | 230,920 KB |
| 実行使用メモリ | 39,936 KB |
| 最終ジャッジ日時 | 2025-01-26 00:06:39 |
| 合計ジャッジ時間 | 19,338 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 42 TLE * 3 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:48:18: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
48 | for(auto [next,c]:G[now]){
| ^
ソースコード
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define all(v) v.begin(),v.end()
const ll INF = (ll)2e18;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll N, M, P, Y;
cin >> N >> M >> P >> Y;
ll ans = 0;
vector<ll> A(M), B(M), C(M);
vector<vector<pair<ll, ll>>> G(N);
rep(i,M){
cin >> A[i] >> B[i] >> C[i];
A[i]--;
B[i]--;
G[A[i]].push_back({B[i], C[i]});
G[B[i]].push_back({A[i], C[i]});
}
unordered_map<ll, ll> memo;
vector<bool> valid(N, false);
vector<ll> D(P), E(P);
rep(i,P){
cin >> D[i] >> E[i];
D[i]--;
valid[D[i]] = true;
memo[D[i]] = E[i];
}
vector<ll> dist(N, INF);
dist[0] = 0;
priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;
pq.push({0, 0});
while(!pq.empty()){
ll now = pq.top().second;
ll d = pq.top().first;
pq.pop();
for(auto [next,c]:G[now]){
if(dist[next]>dist[now]+c){
dist[next] = dist[now] + c;
pq.push({dist[next], next});
}
}
}
rep(i,N){
if(dist[i]>=Y||!valid[i]){
continue;
}
ans = max(ans, (Y - dist[i]) / memo[i]);
}
cout << ans << endl;
}
it_is_a_pity_