結果

問題 No.2712 Play more!
ユーザー nononnonon
提出日時 2024-03-31 15:07:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,160 bytes
コンパイル時間 2,205 ms
コンパイル使用メモリ 211,464 KB
実行使用メモリ 528,592 KB
最終ジャッジ日時 2024-03-31 15:08:08
合計ジャッジ時間 46,521 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 1,538 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 1,532 ms
20,436 KB
testcase_04 WA -
testcase_05 AC 1,533 ms
6,676 KB
testcase_06 AC 1,536 ms
6,676 KB
testcase_07 AC 1,532 ms
6,676 KB
testcase_08 AC 1,531 ms
6,676 KB
testcase_09 AC 1,534 ms
6,676 KB
testcase_10 WA -
testcase_11 AC 1,535 ms
69,808 KB
testcase_12 AC 1,534 ms
12,460 KB
testcase_13 AC 1,535 ms
69,800 KB
testcase_14 AC 1,539 ms
6,676 KB
testcase_15 AC 1,534 ms
36,960 KB
testcase_16 AC 1,534 ms
266,444 KB
testcase_17 AC 1,557 ms
266,420 KB
testcase_18 AC 1,556 ms
36,868 KB
testcase_19 AC 1,561 ms
135,312 KB
testcase_20 AC 1,537 ms
69,820 KB
testcase_21 AC 1,534 ms
266,356 KB
testcase_22 AC 1,539 ms
20,664 KB
testcase_23 MLE -
testcase_24 AC 1,535 ms
69,800 KB
testcase_25 MLE -
testcase_26 AC 1,540 ms
20,612 KB
testcase_27 AC 1,531 ms
6,676 KB
testcase_28 AC 3 ms
6,676 KB
testcase_29 AC 1,534 ms
69,800 KB
testcase_30 AC 1,534 ms
12,460 KB
testcase_31 AC 11 ms
6,676 KB
testcase_32 AC 6 ms
6,676 KB
testcase_33 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int N,M,A[2525];
vector<pair<int,long>>G[2525];
long H[2525];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int ti=clock();
    cin>>N>>M;
    for(int i=0;i<N;i++)cin>>A[i];
    for(;M--;)
    {
        int u,v,w;
        cin>>u>>v>>w;
        u--,v--;
        G[u].push_back(make_pair(v,w));
    }
    for(int i=0;i<N;i++)H[i]=-1L<<60;
    priority_queue<pair<long,int>>q;
    q.push(make_pair(A[0],0));
    H[0]=A[0];
    while(!q.empty())
    {
        double t=(double)(clock()-ti)/CLOCKS_PER_SEC;
        if(t>1.5)
        {
            cout<<"inf"<<endl;
            return 0;
        }
        auto[d,u]=q.top();
        q.pop();
        if(H[u]>d)continue;
        if(u==N-1)continue;
        for(auto[v,w]:G[u])
        {
            if(H[v]<d-w+A[v])
            {
                // if(-(1L<<60)<H[v])
                // {
                //     cout<<"inf"<<endl;
                //     return 0;
                // }
                H[v]=d-w+A[v];
                q.push(make_pair(H[v],v));
            }
        }
    }
    assert(-(1L<<60)<H[N-1]);
    cout<<H[N-1]<<endl;
}
0