結果

問題 No.1242 高橋君とすごろく
ユーザー shotoyooshotoyoo
提出日時 2020-10-02 23:19:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 947 bytes
コンパイル時間 684 ms
コンパイル使用メモリ 87,184 KB
実行使用メモリ 71,840 KB
最終ジャッジ日時 2023-09-27 08:45:52
合計ジャッジ時間 3,630 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
71,620 KB
testcase_01 AC 81 ms
71,388 KB
testcase_02 AC 84 ms
71,524 KB
testcase_03 AC 85 ms
71,632 KB
testcase_04 AC 86 ms
71,840 KB
testcase_05 AC 79 ms
71,692 KB
testcase_06 AC 82 ms
71,716 KB
testcase_07 AC 81 ms
71,384 KB
testcase_08 AC 83 ms
71,536 KB
testcase_09 AC 85 ms
71,496 KB
testcase_10 AC 85 ms
71,500 KB
testcase_11 AC 84 ms
71,492 KB
testcase_12 AC 84 ms
71,620 KB
testcase_13 AC 81 ms
71,696 KB
testcase_14 AC 79 ms
71,388 KB
testcase_15 AC 79 ms
71,500 KB
testcase_16 AC 80 ms
71,780 KB
testcase_17 AC 82 ms
71,692 KB
testcase_18 AC 82 ms
71,804 KB
testcase_19 AC 81 ms
71,532 KB
testcase_20 AC 83 ms
71,328 KB
testcase_21 AC 80 ms
71,492 KB
testcase_22 AC 81 ms
71,492 KB
testcase_23 AC 82 ms
71,764 KB
testcase_24 AC 79 ms
71,756 KB
testcase_25 AC 78 ms
71,516 KB
testcase_26 AC 81 ms
71,588 KB
testcase_27 AC 81 ms
71,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
from heapq import heapify, heappop as hpp, heappush as hp
h = [-item for item in a]
heapify(h)
ren = 0
from collections import deque
l = []
while h:
    v = hpp(h)
    v *= -1
#     print(l,v)
    nl = []
    flg = False
    for item in l:
        d = abs(item-v)
        if d==1:
            if v-3>=0:
                hp(h, -(v-3))
            flg = True
        elif d==3:
            if v-2>=0:
                hp(h, -(v-2))
        elif d==5:
            if v-1>=0:
                hp(h, -(v-1))
        if 0<=d<5:
            nl.append(item)
    nl.append(v)
    if flg:
        ren += 1
    else:
        ren = 0
    l = nl
    pv = v
    if ren>=4 or v==1:
        ans = "No"
        break
else:
    ans = "Yes"
print(ans)
0