結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,772 KB
testcase_01 AC 18 ms
8,860 KB
testcase_02 AC 18 ms
8,908 KB
testcase_03 AC 18 ms
8,848 KB
testcase_04 AC 17 ms
8,780 KB
testcase_05 AC 17 ms
8,780 KB
testcase_06 AC 18 ms
8,688 KB
testcase_07 AC 17 ms
8,792 KB
testcase_08 AC 17 ms
8,780 KB
testcase_09 AC 17 ms
8,836 KB
testcase_10 AC 18 ms
8,912 KB
testcase_11 AC 18 ms
8,704 KB
testcase_12 AC 18 ms
8,828 KB
testcase_13 AC 18 ms
8,832 KB
testcase_14 AC 18 ms
8,796 KB
testcase_15 AC 19 ms
8,748 KB
testcase_16 AC 18 ms
8,740 KB
testcase_17 AC 19 ms
8,752 KB
testcase_18 AC 19 ms
8,708 KB
testcase_19 AC 19 ms
8,800 KB
testcase_20 AC 19 ms
8,884 KB
testcase_21 AC 19 ms
8,724 KB
testcase_22 AC 19 ms
8,860 KB
testcase_23 AC 18 ms
8,864 KB
testcase_24 AC 18 ms
8,860 KB
testcase_25 AC 18 ms
8,852 KB
testcase_26 AC 19 ms
8,904 KB
testcase_27 AC 18 ms
8,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from operator import itemgetter
from itertools import *
from bisect import *
from collections import *
from heapq import *
import sys

sys.setrecursionlimit(10**6)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def MI(): return map(int, sys.stdin.buffer.readline().split())
def MI1(): return map(int1, sys.stdin.buffer.readline().split())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.buffer.readline()[:-1]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def solve(aa):
    fin=set(aa)
    aa=[-a for a in aa]
    heapify(aa)
    q=deque()
    sep=-100
    while aa:
        a=-heappop(aa)
        if len(q)==4:q.pop()
        # print(a,aa,q)
        if a==1:return False
        if a<1:return True
        if a+5 in q:
            sep=a-9
            if a-1 not in fin:
                heappush(aa,-a+1)
                fin.add(a-1)
        if a+3 in q:
            sep=a-5
            if a-2 not in fin:
                heappush(aa, -a+2)
                fin.add(a-2)
        if a+1 in q:
            sep=a-8
            if a-3 not in fin:
                heappush(aa,-a+3)
                fin.add(a-3)
        if sep>=1:return False
        q.appendleft(a)
    return True

n,k=MI()
aa=LI()
if solve(aa):print("Yes")
else:print("No")
0