結果
| 問題 |
No.3013 ハチマキ買い星人
|
| コンテスト | |
| ユーザー |
sai
|
| 提出日時 | 2025-01-25 13:22:15 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 226 ms / 2,000 ms |
| コード長 | 844 bytes |
| コンパイル時間 | 3,583 ms |
| コンパイル使用メモリ | 286,660 KB |
| 実行使用メモリ | 18,544 KB |
| 最終ジャッジ日時 | 2025-01-25 22:45:08 |
| 合計ジャッジ時間 | 10,936 ms |
|
ジャッジサーバーID (参考情報) |
judge10 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 45 |
ソースコード
#include <bits/stdc++.h>
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int N, M, P; long long Y; std::cin >> N >> M >> P >> Y;
std::vector<std::vector<std::pair<int, int>>> G(N);
for (;M--;) {
int a, b, c; std::cin >> a >> b >> c; a--, b--;
G[a].emplace_back(b, c);
G[b].emplace_back(a, c);
}
const long long INF = 1LL << 60;
std::priority_queue<std::pair<long long, int>> pq;
std::vector<long long> dist(N, INF);
pq.emplace(0, 0);
while (pq.size()) {
auto [c, v] = pq.top(); pq.pop();
c *= -1;
if (dist[v] > c) {
dist[v] = c;
for (auto [v2, d] : G[v]) {
pq.emplace(-(c + d), v2);
}
}
}
long long ans = 0;
for (;P--;) {
int D, E; std::cin >> D >> E; D--;
ans = std::max(ans, (Y - dist[D]) / E);
}
std::cout << ans << '\n';
}
sai