結果
問題 |
No.3013 ハチマキ買い星人
|
ユーザー |
![]() |
提出日時 | 2025-01-28 14:38:34 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,202 bytes |
コンパイル時間 | 595 ms |
コンパイル使用メモリ | 64,612 KB |
実行使用メモリ | 17,416 KB |
最終ジャッジ日時 | 2025-01-28 14:39:03 |
合計ジャッジ時間 | 8,583 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 11 WA * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:38:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 38 | scanf("%d%d%d%lld", &n, &m, &p, &y); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:42:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 42 | scanf("%d%d%d", &u, &v, &w); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~ main.cpp:50:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 50 | scanf("%d%d", &di, &ei), di--; | ~~~~~^~~~~~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*- * * 3013.cc: No.3013 繝上メ繝槭く雋キ縺・弌莠コ - yukicoder */ #include<cstdio> #include<vector> #include<queue> #include<algorithm> #include<utility> using namespace std; /* constant */ const int MAX_N = 200000; /* typedef */ using ll = long long; using pii = pair<int,int>; using pli = pair<ll,int>; using vpii = vector<pii>; /* global variables */ vpii nbrs[MAX_N]; int es[MAX_N]; ll ds[MAX_N]; /* subroutines */ /* main */ int main() { int n, m, p; ll y; scanf("%d%d%d%lld", &n, &m, &p, &y); for (int i = 0; i < m; i++) { int u, v, w; scanf("%d%d%d", &u, &v, &w); u--, v--; nbrs[u].push_back({v, w}); nbrs[v].push_back({u, w}); } for (int i = 0; i < p; i++) { int di, ei; scanf("%d%d", &di, &ei), di--; es[di] = ei; } ds[0] = y; priority_queue<pli> q; q.push({y, 0}); ll maxh = 0; while (! q.empty()) { auto [ud, u] = q.top(); q.pop(); if (ds[u] != ud) continue; if (es[u] > 0) maxh = max(maxh, ud / es[u]); for (auto [v, w]: nbrs[u]) { int vd = ud - w; if (ds[v] < vd) ds[v] = vd, q.push({vd, v}); } } printf("%lld\n", maxh); return 0; }