結果
問題 |
No.3013 ハチマキ買い星人
|
ユーザー |
|
提出日時 | 2025-01-25 14:38:47 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 944 bytes |
コンパイル時間 | 1,886 ms |
コンパイル使用メモリ | 171,808 KB |
実行使用メモリ | 8,784 KB |
最終ジャッジ日時 | 2025-01-25 23:24:19 |
合計ジャッジ時間 | 9,267 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge9 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 2 RE * 43 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:25:10: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions] 25 | auto [c, f] = q.top(); q.pop(); | ^ main.cpp:27:15: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions] 27 | for (auto [k, d] : v[f]) { | ^
ソースコード
#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; }