結果
| 問題 |
No.3013 ハチマキ買い星人
|
| ユーザー |
|
| 提出日時 | 2025-02-01 20:24:37 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,030 bytes |
| コンパイル時間 | 4,625 ms |
| コンパイル使用メモリ | 284,496 KB |
| 実行使用メモリ | 27,392 KB |
| 最終ジャッジ日時 | 2025-02-01 20:26:03 |
| 合計ジャッジ時間 | 84,942 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 TLE * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int N, M, P;
ll Y;
cin >> N >> M >> P >> Y;
vector<vector<pair<int, int>>> adj(N);
for (int i = 0; i < M; i++) {
int a, b, c;
cin >> a >> b >> c;
a--, b--;
adj[a].push_back({b, c});
adj[b].push_back({a, c});
}
priority_queue<pair<ll, int>> pq;
pq.push({0, 0});
vector<ll> dist(N, 1e18);
dist[0] = 0;
while(!pq.empty()) {
auto [d, v] = pq.top();
pq.pop();
if(dist[v] != d) continue;
for(const auto&[to, cst]: adj[v]) {
if(dist[to] > dist[v] + cst) {
dist[to] = dist[v] + cst;
pq.push({dist[to], to});
}
}
}
ll ans = 0;
while(P--) {
int d, e;
cin >> d >> e;
d--;
ll cur = Y - dist[d];
cur /= e;
ans = max(ans, cur);
}
cout << ans << '\n';
}