結果
| 問題 |
No.3013 ハチマキ買い星人
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-01-25 14:40:45 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 944 bytes |
| コンパイル時間 | 4,442 ms |
| コンパイル使用メモリ | 284,944 KB |
| 実行使用メモリ | 8,704 KB |
| 最終ジャッジ日時 | 2025-01-25 23:26:41 |
| 合計ジャッジ時間 | 12,862 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 2 RE * 43 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using xy = array<int, 2>;
int main() {
int n, m, p, y; cin >> n >> m >> p >> y;
vector<int> r(n, INT_MAX);
vector<vector<xy>> v(n, vector<xy>(0));
for (int i = 0; i < m; i++) {
int a, b, c; cin >> a >> b >> c; --a; --b;
v[a].push_back({b, c});
v[b].push_back({a, c});
}
for (int i = 0; i < p; i++) {
int a, b; cin >> a >> b; --a;
r[a] = min(r[a], b);
}
priority_queue<xy, vector<xy>, greater<xy>> q;
q.push({0, 0});
vector<int> dist(n, INT_MAX);
while (!q.empty()) {
auto [c, f] = q.top(); q.pop();
dist[f] = c;
for (auto [k, d] : v[f]) {
if (dist[k] == INT_MAX) {
q.push({c+d, k});
}
}
while (!q.empty() && dist[q.top()[1]] != INT_MAX) q.pop();
}
int ans = 0;
for (int i = 0; i < n; i++) {
if (r[i] == INT_MAX) continue;
ans = max(ans, (y - dist[i]) / r[i]);
}
cout << ans << endl;
}