結果
| 問題 |
No.3013 ハチマキ買い星人
|
| ユーザー |
|
| 提出日時 | 2025-01-25 15:24:13 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,605 bytes |
| コンパイル時間 | 5,828 ms |
| コンパイル使用メモリ | 332,328 KB |
| 実行使用メモリ | 20,940 KB |
| 最終ジャッジ日時 | 2025-01-25 23:45:57 |
| 合計ジャッジ時間 | 17,422 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 27 WA * 18 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using mint = atcoder::static_modint<998244353>;
// using mint = atcoder::static_modint<1000000007>;
using namespace std;
using namespace atcoder;
using ld = long double;
using ll = long long;
#define mp(a,b) make_pair(a,b)
#define rep(i,s,n) for(int i=s; i<n; i++)
const vector<int> dx{1,0,-1,0},dy{0,1,0,-1};
struct dijkstra{
public:
dijkstra():_n(0){}
dijkstra(int n):_n(n),G(n){}
void add_edge(int from,int to,ll d){
G[from].push_back({to,d});
}
vector<ll> start_from(int start){
vector<ll> dist(_n,-1);
priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> Q;
Q.push({0,start});
dist[start]=0;
while(!Q.empty()){
auto p=Q.top();
Q.pop();
int now=p.second;
ll d=p.first;
if(d!=dist[now])continue;
for(auto e:G[now]){
int to=e.first;
ll w=e.second;
if(dist[to]==-1 || w+d<dist[to])Q.push(mp(w+d,to)),dist[to]=w+d;
}
}
return dist;
}
private:
int _n;
vector<vector<pair<int,ll>>> G;
};
int main(){
ll n,m,p,y;cin >> n >> m >> p >> y;
dijkstra G(n);
rep(i,0,m){
int a,b;cin >> a >> b;
ll c;cin >> c;
a--,b--;
G.add_edge(a,b,c);
swap(a,b);
G.add_edge(a,b,c);
}
auto dist=G.start_from(0);
ll ans=0;
rep(i,0,p){
ll d,e;cin >> d >> e;
d--;
ans=max(ans,max(0LL,y-dist[d])/e);
}
cout << ans;
}