結果

問題 No.1242 高橋君とすごろく
ユーザー qumazakiqumazaki
提出日時 2020-10-03 01:27:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 601 bytes
コンパイル時間 381 ms
コンパイル使用メモリ 86,900 KB
実行使用メモリ 71,468 KB
最終ジャッジ日時 2023-09-27 08:47:11
合計ジャッジ時間 3,945 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,208 KB
testcase_01 AC 74 ms
71,244 KB
testcase_02 AC 74 ms
71,100 KB
testcase_03 AC 75 ms
71,296 KB
testcase_04 AC 75 ms
71,256 KB
testcase_05 AC 74 ms
71,236 KB
testcase_06 AC 71 ms
71,248 KB
testcase_07 AC 72 ms
71,240 KB
testcase_08 AC 73 ms
71,244 KB
testcase_09 AC 72 ms
71,256 KB
testcase_10 AC 72 ms
71,400 KB
testcase_11 AC 72 ms
71,432 KB
testcase_12 AC 71 ms
71,236 KB
testcase_13 AC 73 ms
71,116 KB
testcase_14 AC 72 ms
71,368 KB
testcase_15 AC 73 ms
71,240 KB
testcase_16 AC 73 ms
71,096 KB
testcase_17 AC 73 ms
71,468 KB
testcase_18 AC 72 ms
71,204 KB
testcase_19 AC 72 ms
71,368 KB
testcase_20 AC 73 ms
71,208 KB
testcase_21 AC 73 ms
71,436 KB
testcase_22 AC 72 ms
71,240 KB
testcase_23 AC 72 ms
71,144 KB
testcase_24 AC 71 ms
71,144 KB
testcase_25 AC 72 ms
71,140 KB
testcase_26 AC 74 ms
71,152 KB
testcase_27 AC 72 ms
71,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k = map(int,input().split())
a = list(map(int,input().split()))

flag = 0
start = 0
for i in range(k-1):
    if(a[i+1] - a[i] in [1,3,5]):
        flag=1
        start = a[i+1]

if(flag==0):
    print('Yes')
    exit()

if(start > 20):
    print('No')
    exit()

dp = [0] * (min(n,start)+1)
for ai in a:
    if(ai > start):
        break
    dp[ai] = 1

for i in range(len(dp)-1,0,-1):
    if(dp[i]==0):
        continue
    for j,b in zip([i-1,i-3,i-5],[i-4,i-5,i-6]):
        if(j>0)&(b>0):
            if(dp[j]==1):
                dp[b] = 1

if(dp[1]==1):
    print('No')
else:
    print('Yes')
0