結果

問題 No.1242 高橋君とすごろく
ユーザー tamato
提出日時 2020-10-02 22:20:52
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 1,073 bytes
コンパイル時間 135 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-07-20 02:47:30
合計ジャッジ時間 1,946 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    from heapq import heappop, heappush, heapify
    input = sys.stdin.readline

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

    B = [-a for a in A]
    S = {a for a in A}
    heapify(B)

    flg = 1
    b_prev = 10**20
    cnt = 0
    while B:
        b = -heappop(B)
        if b == b_prev - 1:
            cnt += 1
        else:
            cnt = 0
        b_prev = b
        if cnt == 6:
            flg = 0
            break
        if b == 1:
            flg = 0
            break
        elif b <= 0:
            break
        if b - 1 in S:
            if b-4 not in S:
                S.add(b - 4)
                heappush(B, -(b-4))
        if b - 3 in S:
            if b-5 not in S:
                S.add(b - 5)
                heappush(B, -(b-5))
        if b - 5 in S:
            if b-6 not in S:
                S.add(b - 6)
                heappush(B, -(b-6))
    if flg:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()
0