結果

問題 No.1242 高橋君とすごろく
ユーザー anagohirameanagohirame
提出日時 2020-10-02 22:30:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 597 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 87,248 KB
実行使用メモリ 75,800 KB
最終ジャッジ日時 2023-09-27 08:41:45
合計ジャッジ時間 3,818 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,528 KB
testcase_01 AC 71 ms
71,484 KB
testcase_02 AC 72 ms
71,368 KB
testcase_03 AC 71 ms
71,424 KB
testcase_04 AC 71 ms
71,568 KB
testcase_05 AC 72 ms
71,268 KB
testcase_06 AC 72 ms
71,292 KB
testcase_07 AC 72 ms
71,372 KB
testcase_08 AC 71 ms
71,412 KB
testcase_09 AC 73 ms
71,396 KB
testcase_10 AC 75 ms
75,524 KB
testcase_11 AC 75 ms
75,692 KB
testcase_12 AC 75 ms
75,744 KB
testcase_13 AC 75 ms
75,720 KB
testcase_14 AC 73 ms
75,740 KB
testcase_15 AC 76 ms
75,764 KB
testcase_16 AC 76 ms
75,676 KB
testcase_17 AC 72 ms
71,392 KB
testcase_18 AC 72 ms
71,388 KB
testcase_19 AC 73 ms
71,420 KB
testcase_20 AC 76 ms
75,704 KB
testcase_21 AC 72 ms
71,372 KB
testcase_22 AC 75 ms
75,672 KB
testcase_23 AC 74 ms
75,684 KB
testcase_24 AC 74 ms
75,780 KB
testcase_25 AC 75 ms
75,764 KB
testcase_26 AC 75 ms
75,800 KB
testcase_27 AC 71 ms
71,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import exit
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(k-1):
	for j in range(i+1, k):
		if a[j] - a[i] == 1:
			if a[i] not in {2, 3, 5, 8}:
				print("No")
				exit()
		elif a[j] - a[i] == 3:
			if a[i] not in {2, 5}:
				print("No")
				exit()
		elif a[j] - a[i] == 5:
			if a[i] not in {3, 4, 6, 9}:
				print("No")
				exit()
dp = [True for _ in range(25)]
for x in a:
	if x < 25:
		dp[x] = False

for i in range(18, 0, -1):
	for j in range(1, 4):
		if dp[i+j] == False and dp[i+7-j] == False:
			dp[i] = False

print("Yes" if dp[1] else "No")
0