結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 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 2 ms
6,676 KB
testcase_07 AC 4 ms
6,676 KB
testcase_08 AC 4 ms
6,676 KB
testcase_09 AC 4 ms
6,676 KB
testcase_10 WA -
testcase_11 AC 60 ms
12,288 KB
testcase_12 AC 69 ms
6,676 KB
testcase_13 AC 77 ms
20,604 KB
testcase_14 AC 184 ms
6,676 KB
testcase_15 AC 295 ms
37,104 KB
testcase_16 AC 12 ms
8,140 KB
testcase_17 AC 12 ms
8,244 KB
testcase_18 AC 30 ms
6,676 KB
testcase_19 AC 4 ms
6,676 KB
testcase_20 AC 30 ms
8,160 KB
testcase_21 AC 13 ms
8,192 KB
testcase_22 AC 182 ms
20,540 KB
testcase_23 AC 10 ms
6,676 KB
testcase_24 AC 34 ms
12,400 KB
testcase_25 AC 18 ms
12,280 KB
testcase_26 AC 17 ms
6,676 KB
testcase_27 AC 188 ms
6,676 KB
testcase_28 AC 2 ms
6,676 KB
testcase_29 AC 36 ms
12,396 KB
testcase_30 AC 251 ms
12,476 KB
testcase_31 AC 4 ms
6,676 KB
testcase_32 AC 4 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] >= 10*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