結果
| 問題 |
No.3013 ハチマキ買い星人
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-02-22 01:56:28 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 240 ms / 2,000 ms |
| コード長 | 1,064 bytes |
| コンパイル時間 | 4,491 ms |
| コンパイル使用メモリ | 257,852 KB |
| 実行使用メモリ | 21,736 KB |
| 最終ジャッジ日時 | 2025-02-22 01:56:40 |
| 合計ジャッジ時間 | 11,264 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 45 |
ソースコード
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (ll i = s; i < (ll)(t); i++)
template<typename T>
bool chmin(T &x, T y) { return x > y ? (x = y, true) : false; }
template<typename T>
bool chmax(T &x, T y) { return x < y ? (x = y, true) : false; }
struct io_setup {
io_setup() {
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
cout << fixed << setprecision(15);
}
} io_setup;
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<int> d(p),e(p);
rep(i,0,p) cin>>d[i]>>e[i];
rep(i,0,p) d[i]--;
priority_queue<pair<ll,ll>> pq;
vector<ll> cost(n,-1);
pq.push({y,0});
while(!pq.empty()){
auto[cs,nw]=pq.top();
pq.pop();
if(cost[nw]!=-1) continue;
cost[nw]=cs;
for(auto[nx,ad]:g[nw]){
if(cost[nx]!=-1) continue;
pq.push({max(0ll,cs-ad),nx});
}
}
ll ans=0;
rep(i,0,p){
chmax(ans,cost[d[i]]/e[i]);
}
cout<<ans<<"\n";
}