結果

問題 No.2712 Play more!
ユーザー shobonvipshobonvip
提出日時 2024-04-01 01:54:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,006 bytes
コンパイル時間 4,496 ms
コンパイル使用メモリ 263,900 KB
実行使用メモリ 11,572 KB
最終ジャッジ日時 2024-04-01 01:55:10
合計ジャッジ時間 9,518 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
11,444 KB
testcase_01 AC 14 ms
11,444 KB
testcase_02 AC 14 ms
11,444 KB
testcase_03 AC 19 ms
11,444 KB
testcase_04 AC 14 ms
11,444 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 51 ms
11,444 KB
testcase_10 AC 14 ms
11,444 KB
testcase_11 AC 132 ms
11,444 KB
testcase_12 AC 82 ms
11,444 KB
testcase_13 AC 119 ms
11,444 KB
testcase_14 AC 50 ms
11,444 KB
testcase_15 AC 321 ms
11,444 KB
testcase_16 AC 196 ms
11,444 KB
testcase_17 AC 106 ms
11,444 KB
testcase_18 AC 42 ms
11,444 KB
testcase_19 AC 44 ms
11,444 KB
testcase_20 AC 175 ms
11,444 KB
testcase_21 AC 449 ms
11,444 KB
testcase_22 AC 139 ms
11,444 KB
testcase_23 AC 430 ms
11,444 KB
testcase_24 AC 100 ms
11,444 KB
testcase_25 AC 241 ms
11,444 KB
testcase_26 AC 40 ms
11,444 KB
testcase_27 AC 22 ms
11,444 KB
testcase_28 AC 18 ms
11,444 KB
testcase_29 AC 103 ms
11,444 KB
testcase_30 AC 108 ms
11,444 KB
testcase_31 AC 122 ms
11,572 KB
testcase_32 AC 76 ms
11,444 KB
testcase_33 AC 15 ms
11,444 KB
testcase_34 AC 14 ms
11,444 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;
}

//defmodfact
const int COMinitMAX = 998244;
mint fact[COMinitMAX+1], factinv[COMinitMAX+1];

void modfact(){
	fact[0] = 1;
	for (int i=1; i<=COMinitMAX; i++){
		fact[i] = fact[i-1] * i;
	}
	factinv[COMinitMAX] = fact[COMinitMAX].inv();
	for (int i=COMinitMAX-1; i>=0; i--){
		factinv[i] = factinv[i+1] * (i+1);
	}
}

mint cmb(int a, int b){
	if (a<b || b<0) return mint(0);
	return fact[a]*factinv[b]*factinv[a-b];
}
//--------


int main(){
	modfact();
	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,3*m+1){
		rep(j,0,m){
			chmin(d[v[j]], d[u[j]] + c[j]);
		}
		if (i == m){
			memo1 = d[n-1];
		}else if(i == 3*m){
			memo2 = d[n-1];
		}
	}
	if (memo1 > memo2){
		cout << "inf" << '\n';
	}else{
		cout << -memo2 << '\n';
	}
}

0