結果

問題 No.1242 高橋君とすごろく
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2020-10-02 21:43:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 1,012 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 87,004 KB
実行使用メモリ 71,584 KB
最終ジャッジ日時 2023-09-27 08:37:09
合計ジャッジ時間 3,702 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,544 KB
testcase_01 AC 76 ms
71,548 KB
testcase_02 AC 75 ms
71,384 KB
testcase_03 AC 74 ms
71,372 KB
testcase_04 AC 74 ms
71,320 KB
testcase_05 AC 75 ms
71,380 KB
testcase_06 AC 76 ms
71,328 KB
testcase_07 AC 74 ms
71,316 KB
testcase_08 AC 77 ms
71,436 KB
testcase_09 AC 76 ms
71,232 KB
testcase_10 AC 75 ms
71,092 KB
testcase_11 AC 75 ms
71,432 KB
testcase_12 AC 77 ms
71,460 KB
testcase_13 AC 76 ms
71,052 KB
testcase_14 AC 77 ms
71,420 KB
testcase_15 AC 77 ms
71,464 KB
testcase_16 AC 77 ms
71,352 KB
testcase_17 AC 77 ms
71,436 KB
testcase_18 AC 79 ms
71,440 KB
testcase_19 AC 76 ms
71,376 KB
testcase_20 AC 76 ms
71,360 KB
testcase_21 AC 77 ms
71,584 KB
testcase_22 AC 77 ms
71,544 KB
testcase_23 AC 77 ms
71,264 KB
testcase_24 AC 77 ms
71,380 KB
testcase_25 AC 76 ms
71,264 KB
testcase_26 AC 76 ms
71,436 KB
testcase_27 AC 76 ms
71,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

https://yukicoder.me/problems/no/1242

2個の不可能マスが1つの不可能マスを作る
作るのは、1,3,5距離の不可能マスだけ
4つ連続だと確実にアウト

"""

from sys import stdin
import heapq
import sys

N,K = map(int,stdin.readline().split())
A = list(map(int,stdin.readline().split()))

q = []
d = {}
for i in A:
    heapq.heappush(q,-1*i)
    d[i] = 1


cnt = 0
last = float("inf")

while len(q) > 0:

    now = -1 * heapq.heappop(q)
    if now < 0:
        break
        
    if now == last-1:
        cnt += 1
    else:
        cnt = 1
    last = now
    
    if cnt >= 4:
        print ("No")
        sys.exit()

    if now+1 in d and now-3 not in d:
        d[now-3] = 1
        heapq.heappush(q,-1*(now-3))
    if now+3 in d and now-2 not in d:
        d[now-2] = 1
        heapq.heappush(q,-1*(now-2))
    if now+5 in d and now-1 not in d:
        d[now-1] = 1
        heapq.heappush(q,-1*(now-1))

#print (d)
if 1 not in d:
    print ("Yes")
else:
    print ("No")
0