結果
| 問題 |
No.2712 Play more!
|
| ユーザー |
|
| 提出日時 | 2024-03-31 13:59:01 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 597 bytes |
| コンパイル時間 | 798 ms |
| コンパイル使用メモリ | 64,896 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-09-30 18:44:34 |
| 合計ジャッジ時間 | 2,234 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 WA * 4 |
ソースコード
#include<iostream>
#include<cassert>
using namespace std;
int N,M;
int A[2525];
int a[5000],b[5000],c[5000];
long dist[2525];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>N>>M;
for(int i=0;i<N;i++)
{
cin>>A[i];
dist[i]=-1e18;
}
for(int i=0;i<M;i++)
{
cin>>a[i]>>b[i]>>c[i];
a[i]--,b[i]--;
}
dist[0]=A[0];
for(int t=1;t<=3*N;t++)
{
long pr=dist[N-1];
for(int i=0;i<M;i++)if(dist[a[i]]>(long)-1e18)
{
dist[b[i]]=max(dist[b[i]],dist[a[i]]-c[i]+A[b[i]]);
}
if(pr<dist[N-1]&&t>=N)
{
cout<<"inf\n";
return 0;
}
}
cout<<dist[N-1]<<endl;
}