結果

問題 No.1242 高橋君とすごろく
ユーザー keijakkeijak
提出日時 2020-10-03 00:13:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,031 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 11,028 KB
実行使用メモリ 8,752 KB
最終ジャッジ日時 2023-09-25 00:35:23
合計ジャッジ時間 4,207 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,336 KB
testcase_01 AC 15 ms
8,196 KB
testcase_02 AC 16 ms
8,388 KB
testcase_03 AC 15 ms
8,216 KB
testcase_04 AC 16 ms
8,196 KB
testcase_05 AC 16 ms
8,264 KB
testcase_06 AC 16 ms
8,188 KB
testcase_07 AC 16 ms
8,196 KB
testcase_08 AC 16 ms
8,260 KB
testcase_09 AC 16 ms
8,344 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()


def find_item(x, a):
    if x <= 0:
        return False
    n = len(a)
    for i in range(n - 1, -1, -1):
        if a[i] == x:
            return True
        if a[i] < x:
            break
    return False


def insert_item(x, a):
    if x <= 0:
        return
    if find_item(x, a):
        return
    a.append(x)
    n = len(a)
    for i in range(n - 2, -1, -1):
        if a[i] < a[i + 1]:
            break
        a[i], a[i + 1] = a[i + 1], a[i]


def solve():
    n, k = inl()
    a = inl()
    a.sort()
    while a:
        x = a.pop()
        if x == 1:
            return False
        if find_item(x - 1, a):
            insert_item(x - 4, a)
        if find_item(x - 3, a):
            insert_item(x - 5, a)
        if find_item(x - 5, a):
            insert_item(x - 6, a)
    return True


print("Yes" if solve() else "No")
0