結果
| 問題 |
No.2712 Play more!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-01-23 03:40:17 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 827 bytes |
| コンパイル時間 | 4,332 ms |
| コンパイル使用メモリ | 254,040 KB |
| 最終ジャッジ日時 | 2025-02-18 22:12:11 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 WA * 2 |
ソースコード
#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);
bool update = false;
cost[0] = A[0];
for (int i = 0; i < 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 - 1 == i) update = true;
}
}
}
if (update)
cout << "inf" << endl;
else
cout << cost[N - 1] << endl;
}