結果

問題 No.1242 高橋君とすごろく
ユーザー tamatotamato
提出日時 2020-10-02 22:20:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 1,073 bytes
コンパイル時間 110 ms
コンパイル使用メモリ 11,080 KB
実行使用メモリ 8,640 KB
最終ジャッジ日時 2023-09-27 08:41:14
合計ジャッジ時間 1,748 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,500 KB
testcase_01 AC 16 ms
8,640 KB
testcase_02 AC 17 ms
8,480 KB
testcase_03 AC 17 ms
8,532 KB
testcase_04 AC 17 ms
8,460 KB
testcase_05 AC 16 ms
8,424 KB
testcase_06 AC 17 ms
8,568 KB
testcase_07 AC 16 ms
8,512 KB
testcase_08 AC 16 ms
8,488 KB
testcase_09 AC 16 ms
8,444 KB
testcase_10 AC 17 ms
8,524 KB
testcase_11 AC 16 ms
8,512 KB
testcase_12 AC 17 ms
8,484 KB
testcase_13 AC 16 ms
8,544 KB
testcase_14 AC 16 ms
8,532 KB
testcase_15 AC 17 ms
8,520 KB
testcase_16 AC 16 ms
8,552 KB
testcase_17 AC 17 ms
8,528 KB
testcase_18 AC 16 ms
8,616 KB
testcase_19 AC 17 ms
8,500 KB
testcase_20 AC 17 ms
8,480 KB
testcase_21 AC 17 ms
8,568 KB
testcase_22 AC 17 ms
8,456 KB
testcase_23 AC 17 ms
8,640 KB
testcase_24 AC 16 ms
8,492 KB
testcase_25 AC 16 ms
8,500 KB
testcase_26 AC 17 ms
8,516 KB
testcase_27 AC 16 ms
8,516 KB
権限があれば一括ダウンロードができます

ソースコード

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