結果
| 問題 |
No.3013 ハチマキ買い星人
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-01-25 12:52:11 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,365 bytes |
| コンパイル時間 | 3,622 ms |
| コンパイル使用メモリ | 288,620 KB |
| 実行使用メモリ | 24,564 KB |
| 最終ジャッジ日時 | 2025-01-25 22:25:22 |
| 合計ジャッジ時間 | 24,309 ms |
|
ジャッジサーバーID (参考情報) |
judge8 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 42 TLE * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef local
#include <debug.hpp>
#else
#define debug(...)
#endif
#define rep(i, n) for (int i = 0; i < n; i++)
template <class T> istream& operator>>(istream& I, vector<T>& V) {for (T& X : V) I >> X; return I;}
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
vector<int> di = {-1, 1, 0, 0}, dj = {0, 0, -1, 1}; int inf = 2e9; long INF = 1e18;
int main() {
long y;
int n, m, p;
cin >> n >> m >> p >> y;
vector<vector<pair<int, int>>> g(n);
rep(i, m) {
int u, v, w;
cin >> u >> v >> w;
u--; v--;
g[u].emplace_back(v, w);
g[v].emplace_back(u, w);
}
vector<long> dist(n, INF);
priority_queue<pair<long, int>, vector<pair<long, int>>, greater<pair<long, int>>> q;
dist[0] = 0;
q.emplace(0, 0);
while (q.size()) {
auto [d, v] = q.top(); q.pop();
for (auto [u, w] : g[v]) {
if (chmin(dist[u], d + w)) {
q.emplace(dist[u], u);
}
}
}
long ans = 0;
rep(i, p) {
int d, e;
cin >> d >> e;
d--;
long x = y - dist[d];
chmax(ans, x / e);
}
cout << ans << endl;
return 0;
}