結果
問題 | No.2712 Play more! |
ユーザー |
|
提出日時 | 2024-01-23 03:40:27 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 923 bytes |
コンパイル時間 | 3,827 ms |
コンパイル使用メモリ | 252,496 KB |
最終ジャッジ日時 | 2025-02-18 22:12:29 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 WA * 4 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using ll = long long; const long long INF = 0x1fffffffffffffff; int main() { ll N, M; cin >> N >> M; vector<ll> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } vector<array<long long, 3>> E; for (int i = 0; i < M; i++) { int a, b, c; cin >> a >> b >> c; E.push_back({a - 1, b - 1, A[b - 1] - c}); } vector<long long> cost(N, -INF); vector<bool> update(N); cost[0] = A[0]; for (int i = 0; i < 2*N; i++) { for (auto [from, to, t] : E) { if (cost[from] == -INF) continue; if (cost[to] < cost[from] + t) { cost[to] = cost[from] + t; if(N<=i) update[to] = true; } } } for (int i = 0; i < N; i++) { if (update[i]) cost[i] = INF; } if (cost[N - 1] == INF) cout << "inf" << endl; else cout << cost[N - 1] << endl; }