結果

問題 No.607 開通777年記念
ユーザー Konton7Konton7
提出日時 2019-05-24 01:20:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 534 ms / 2,000 ms
コード長 654 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 11,952 KB
実行使用メモリ 10,460 KB
最終ジャッジ日時 2023-10-17 11:45:13
合計ジャッジ時間 2,298 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,112 KB
testcase_01 AC 30 ms
10,112 KB
testcase_02 AC 30 ms
10,112 KB
testcase_03 AC 31 ms
10,112 KB
testcase_04 AC 30 ms
10,112 KB
testcase_05 AC 30 ms
10,112 KB
testcase_06 AC 29 ms
10,112 KB
testcase_07 AC 64 ms
10,220 KB
testcase_08 AC 31 ms
10,112 KB
testcase_09 AC 35 ms
10,140 KB
testcase_10 AC 29 ms
10,128 KB
testcase_11 AC 482 ms
10,448 KB
testcase_12 AC 534 ms
10,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = [ int(v) for v in input().split() ]
train = [ 0 for i in range(n) ]


def passenger_check(inlist):
	global n
	start, end = 0, 0
	passenger_sum = 0
	check = 0
	for i in range(2*n):
		if end == n and start == n:
			break
		if passenger_sum < 777:
			if end != n:
				passenger_sum += inlist[end]
				end += 1
		elif passenger_sum > 777:
			passenger_sum -= inlist[start]
			start += 1
		if passenger_sum == 777:
			check = 1
			break

	return check

ans = "NO"
for i in range(m):
	station = [ int(v) for v in input().split() ]
	train = [ (train[j] + station[j]) for j in range(n) ]
	if passenger_check(train) == 1:
		ans = "YES"
		break
print(ans)
0