結果
| 問題 |
No.3013 ハチマキ買い星人
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-01-25 13:13:20 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,288 bytes |
| コンパイル時間 | 6,028 ms |
| コンパイル使用メモリ | 283,240 KB |
| 実行使用メモリ | 22,500 KB |
| 最終ジャッジ日時 | 2025-01-25 22:38:26 |
| 合計ジャッジ時間 | 15,911 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 29 WA * 16 |
ソースコード
#include <bits/stdc++.h>
typedef long long ll;
typedef std::pair<long long, long long> P;
typedef std::priority_queue<P, std::vector<P>, std::greater<P>> PQ;
int main()
{
long long n, m, p, y;
std::cin >> n >> m >> p >> y;
std::vector<std::vector<P>> path(n);
std::vector<long long> h(n, -1);
for (int i = 0; i < m; ++i) {
ll a, b, c;
std::cin >> a >> b >> c;
--a, --b;
path[a].push_back({b, c});
path[b].push_back({a, c});
}
for (int i = 0; i < p; ++i) {
ll d, e;
std::cin >> d >> e;
--d;
h[d] = e;
}
std::vector<long long> dist(n, 1e17);
dist[0] = 0;
PQ pq;
pq.push({0, 0});
while (!pq.empty()) {
ll udist = pq.top().first;
ll u = pq.top().second;
pq.pop();
if (udist > dist[u]) continue;
for (auto edge : path[u]) {
ll v = edge.first;
ll c = edge.second;
if (dist[v] > udist + c) {
dist[v] = udist + c;
pq.push({udist + c, v});
}
}
}
ll ans = 0;
for (int i = 0; i < n; ++i) {
if (h[i] == -1) continue;
ll r = y - dist[i];
ans = std::max(ans, r / h[i]);
}
std::cout << ans << std::endl;
}