結果

問題 No.2712 Play more!
ユーザー KKT89KKT89
提出日時 2024-03-31 14:10:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,271 bytes
コンパイル時間 2,685 ms
コンパイル使用メモリ 225,580 KB
実行使用メモリ 12,520 KB
最終ジャッジ日時 2024-03-31 14:10:12
合計ジャッジ時間 4,261 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 WA -
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 1 ms
6,676 KB
testcase_07 AC 3 ms
6,676 KB
testcase_08 AC 3 ms
6,676 KB
testcase_09 AC 3 ms
6,676 KB
testcase_10 WA -
testcase_11 AC 19 ms
6,676 KB
testcase_12 AC 19 ms
6,676 KB
testcase_13 AC 23 ms
8,264 KB
testcase_14 AC 48 ms
6,676 KB
testcase_15 AC 70 ms
12,520 KB
testcase_16 AC 6 ms
6,676 KB
testcase_17 AC 5 ms
6,676 KB
testcase_18 AC 10 ms
6,676 KB
testcase_19 AC 4 ms
6,676 KB
testcase_20 AC 11 ms
6,676 KB
testcase_21 AC 6 ms
6,676 KB
testcase_22 AC 49 ms
8,204 KB
testcase_23 AC 5 ms
6,676 KB
testcase_24 AC 11 ms
6,676 KB
testcase_25 AC 7 ms
6,676 KB
testcase_26 AC 6 ms
6,676 KB
testcase_27 AC 49 ms
6,676 KB
testcase_28 AC 2 ms
6,676 KB
testcase_29 AC 11 ms
6,676 KB
testcase_30 AC 67 ms
8,332 KB
testcase_31 AC 4 ms
6,676 KB
testcase_32 AC 3 ms
6,676 KB
testcase_33 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) { return (ull)rng() % B; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m; cin >> n >> m;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<vector<pair<int,ll>>> g(n);
    for (int i = 0; i < m; ++i) {
        int x,y,z; cin >> x >> y >> z;
        x -= 1, y -= 1;
        g[x].push_back({y, z});
    }
    vector<ll> dp(n, -1e18);
    dp[0] = a[0];
    priority_queue<pair<ll,int>> pq;
    pq.push({dp[0], 0});
    vector<int> cnt(n);
    while (pq.size()) {
        auto p = pq.top(); pq.pop();
        ll score = p.first, j = p.second;
        if (dp[j] != score) continue;
        cnt[j] += 1;
        if (cnt[j] >= 3*n) {
            cout << "inf" << endl;
            return 0;
        }
        for (auto to : g[j]) {
            ll nxt = score - to.second + a[to.first];
            int t = to.first;
            if (dp[t] < nxt) {
                dp[t] = nxt;
                pq.push({nxt, t});
            }
        }
    }
    cout << dp.back() << endl;
}
0