結果

問題 No.2712 Play more!
ユーザー shobonvipshobonvip
提出日時 2024-04-01 01:57:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,567 bytes
コンパイル時間 4,744 ms
コンパイル使用メモリ 263,228 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-01 01:57:49
合計ジャッジ時間 7,201 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 AC 2 ms
6,676 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 37 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 50 ms
6,676 KB
testcase_12 AC 37 ms
6,676 KB
testcase_13 AC 42 ms
6,676 KB
testcase_14 AC 73 ms
6,676 KB
testcase_15 AC 166 ms
6,676 KB
testcase_16 AC 28 ms
6,676 KB
testcase_17 AC 6 ms
6,676 KB
testcase_18 AC 17 ms
6,676 KB
testcase_19 AC 6 ms
6,676 KB
testcase_20 AC 70 ms
6,676 KB
testcase_21 AC 40 ms
6,676 KB
testcase_22 AC 50 ms
6,676 KB
testcase_23 AC 15 ms
6,676 KB
testcase_24 AC 25 ms
6,676 KB
testcase_25 AC 9 ms
6,676 KB
testcase_26 AC 19 ms
6,676 KB
testcase_27 AC 19 ms
6,676 KB
testcase_28 AC 12 ms
6,676 KB
testcase_29 AC 23 ms
6,676 KB
testcase_30 AC 128 ms
6,676 KB
testcase_31 AC 64 ms
6,676 KB
testcase_32 AC 49 ms
6,676 KB
testcase_33 AC 3 ms
6,676 KB
testcase_34 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
//*/

/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/

typedef long long ll;

#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)

template <typename T> bool chmin(T &a, const T &b) {
	if (a <= b) return false;
	a = b;
	return true;
}

template <typename T> bool chmax(T &a, const T &b) {
	if (a >= b) return false;
	a = b;
	return true;
}

template <typename T> T max(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
	return ret;
}

template <typename T> T min(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
	return ret;
}

template <typename T> T sum(vector<T> &a){
	T ret = 0;
	for (int i=0; i<(int)a.size(); i++) ret += a[i];
	return ret;
}


int main(){
	int n, m; cin >> n >> m;
	vector<ll> a(n);
	rep(i,0,n) cin >> a[i];
	
	vector<int> u(m), v(m);
	vector<ll> c(m);
	rep(i,0,m){
		cin >> u[i] >> v[i];
		u[i]--;
		v[i]--;
		cin >> c[i];
		c[i] -= a[v[i]];
	}

	vector<ll> d(n,1e18);
	d[0] = -a[0];
	ll memo1 = 0;
	ll memo2 = 0;
	rep(i,0,4*n+1){
		rep(j,0,m){
			chmin(d[v[j]], d[u[j]] + c[j]);
		}
		if (i == 2*n){
			memo1 = d[n-1];
		}else if(i == 4*n){
			memo2 = d[n-1];
		}
	}
	if (memo1 > memo2){
		cout << "inf" << '\n';
	}else{
		cout << -memo2 << '\n';
	}
}

0