結果

問題 No.2712 Play more!
ユーザー k82bk82b
提出日時 2024-03-31 15:46:29
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 1,183 bytes
コンパイル時間 2,410 ms
コンパイル使用メモリ 198,004 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-03 12:10:52
合計ジャッジ時間 3,829 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 1 ms
6,676 KB
testcase_05 AC 1 ms
6,676 KB
testcase_06 AC 1 ms
6,676 KB
testcase_07 AC 23 ms
6,676 KB
testcase_08 AC 23 ms
6,676 KB
testcase_09 AC 27 ms
6,676 KB
testcase_10 AC 1 ms
6,676 KB
testcase_11 AC 12 ms
6,676 KB
testcase_12 AC 31 ms
6,676 KB
testcase_13 AC 11 ms
6,676 KB
testcase_14 AC 22 ms
6,676 KB
testcase_15 AC 68 ms
6,676 KB
testcase_16 AC 10 ms
6,676 KB
testcase_17 AC 4 ms
6,676 KB
testcase_18 AC 5 ms
6,676 KB
testcase_19 AC 4 ms
6,676 KB
testcase_20 AC 19 ms
6,676 KB
testcase_21 AC 16 ms
6,676 KB
testcase_22 AC 19 ms
6,676 KB
testcase_23 AC 8 ms
6,676 KB
testcase_24 AC 13 ms
6,676 KB
testcase_25 AC 5 ms
6,676 KB
testcase_26 AC 7 ms
6,676 KB
testcase_27 AC 8 ms
6,676 KB
testcase_28 AC 7 ms
6,676 KB
testcase_29 AC 13 ms
6,676 KB
testcase_30 AC 53 ms
6,676 KB
testcase_31 AC 37 ms
6,676 KB
testcase_32 AC 29 ms
6,676 KB
testcase_33 AC 2 ms
6,676 KB
testcase_34 AC 1 ms
6,676 KB
testcase_35 AC 1 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std, core.bitop;
bool chmin(T)(ref T SE, T MI) { if (SE > MI) { SE = MI; return true; } else { return false; } }
bool chmax(T)(ref T SE, T MI) { if (SE < MI) { SE = MI; return true; } else { return false; } }
int lowerBound(T)(T[] SE, T MI) { int lo = -1, hi = cast(int)(SE.length); while (hi - lo > 1) { int mid = lo + hi >> 1; (SE[mid] < MI ? lo : hi) = mid; } return hi; }
int upperBound(T)(T[] SE, T MI) { int lo = -1, hi = cast(int)(SE.length); while (hi - lo > 1) { int mid = lo + hi >> 1; (SE[mid] > MI ? hi : lo) = mid; } return hi; }
void main() {
	int N, M;
	readf("%s %s\n", N, M);
	auto A = readln.chomp.split.to!(int[]);
	auto a = new int[M];
	auto b = new int[M];
	auto c = new int[M];
	foreach (i; 0 .. M) {
		readf("%s %s %s\n", a[i], b[i], c[i]);
		--a[i];
		--b[i];
	}
	bool inf = false;
	auto dist = new long[N];
	dist[] = long.min;
	dist[N - 1] = A[N - 1];
	foreach (i; 0 .. N) {
		bool se = false;
		foreach (j; 0 .. M) {
			if (dist[b[j]] != long.min) {
				if (chmax(dist[a[j]], dist[b[j]] + A[a[j]] - c[j])) {
					se = true;
				}
			}
		}
		if (i == N - 1 && se) {
			inf = true;
		}
	}
	if (inf) {
		"inf".writeln;
	} else {
		dist[0].writeln;
	}
}
0