結果
| 問題 |
No.3013 ハチマキ買い星人
|
| ユーザー |
tnakao0123
|
| 提出日時 | 2025-01-28 14:56:51 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,322 bytes |
| コンパイル時間 | 585 ms |
| コンパイル使用メモリ | 64,660 KB |
| 実行使用メモリ | 96,828 KB |
| 最終ジャッジ日時 | 2025-01-28 14:57:54 |
| 合計ジャッジ時間 | 60,500 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 13 WA * 14 TLE * 18 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:39:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
39 | scanf("%d%d%d%lld", &n, &m, &p, &y);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:43:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
43 | scanf("%d%d%d", &u, &v, &w);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:51:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
51 | 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;
const long long LINF = 1LL << 62;
/* 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;
}
fill(ds, ds + n, LINF);
ds[0] = 0;
priority_queue<pli> q;
q.push({0, 0});
while (! q.empty()) {
auto [ud, u] = q.top(); q.pop();
if (ds[u] != ud) continue;
for (auto [v, w]: nbrs[u]) {
int vd = ud + w;
if (ds[v] > vd) ds[v] = vd, q.push({vd, v});
}
}
ll maxh = 0;
for (int u = 0; u < n; u++)
if (es[u] > 0 && y > ds[u])
maxh = max(maxh, (y - ds[u]) / es[u]);
printf("%lld\n", maxh);
return 0;
}
tnakao0123