結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,548 KB
testcase_01 AC 1,998 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 TLE -
testcase_04 WA -
testcase_05 TLE -
testcase_06 AC 1,983 ms
6,548 KB
testcase_07 AC 1,993 ms
6,548 KB
testcase_08 TLE -
testcase_09 TLE -
testcase_10 TLE -
testcase_11 AC 1,992 ms
69,808 KB
testcase_12 AC 1,990 ms
12,460 KB
testcase_13 TLE -
testcase_14 AC 1,983 ms
6,548 KB
testcase_15 AC 1,998 ms
36,960 KB
testcase_16 AC 1,988 ms
266,444 KB
testcase_17 TLE -
testcase_18 AC 1,990 ms
36,868 KB
testcase_19 TLE -
testcase_20 AC 1,985 ms
69,820 KB
testcase_21 TLE -
testcase_22 TLE -
testcase_23 MLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 AC 1,989 ms
37,000 KB
testcase_27 TLE -
testcase_28 AC 3 ms
6,548 KB
testcase_29 AC 1,984 ms
135,340 KB
testcase_30 AC 1,992 ms
12,460 KB
testcase_31 AC 10 ms
6,548 KB
testcase_32 AC 5 ms
6,548 KB
testcase_33 AC 2 ms
6,548 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.95)
        {
            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