結果

問題 No.1242 高橋君とすごろく
ユーザー buey_tbuey_t
提出日時 2023-03-25 11:34:10
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,278 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 81,696 KB
実行使用メモリ 84,256 KB
最終ジャッジ日時 2023-10-18 22:54:04
合計ジャッジ時間 5,407 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
84,244 KB
testcase_01 AC 129 ms
84,248 KB
testcase_02 AC 130 ms
84,248 KB
testcase_03 AC 130 ms
84,248 KB
testcase_04 AC 130 ms
84,244 KB
testcase_05 AC 132 ms
84,240 KB
testcase_06 AC 130 ms
84,244 KB
testcase_07 AC 130 ms
84,248 KB
testcase_08 AC 129 ms
84,240 KB
testcase_09 AC 130 ms
84,248 KB
testcase_10 AC 129 ms
84,240 KB
testcase_11 AC 130 ms
84,244 KB
testcase_12 AC 131 ms
84,244 KB
testcase_13 AC 131 ms
84,252 KB
testcase_14 AC 130 ms
84,244 KB
testcase_15 AC 132 ms
84,236 KB
testcase_16 WA -
testcase_17 AC 131 ms
84,244 KB
testcase_18 AC 134 ms
84,240 KB
testcase_19 AC 131 ms
84,248 KB
testcase_20 WA -
testcase_21 AC 130 ms
84,248 KB
testcase_22 AC 129 ms
84,240 KB
testcase_23 AC 130 ms
84,244 KB
testcase_24 AC 129 ms
84,236 KB
testcase_25 AC 129 ms
84,240 KB
testcase_26 AC 130 ms
84,248 KB
testcase_27 AC 129 ms
84,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum
    from heapq import heapify, heappop, heappush
    from bisect import bisect_left, bisect_right
    from copy import deepcopy
    import copy
    import random
    from collections import deque,Counter,defaultdict
    from itertools import permutations,combinations
    from decimal import Decimal,ROUND_HALF_UP
    #tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
    from functools import lru_cache, reduce
    #@lru_cache(maxsize=None)
    from operator import add,sub,mul,xor,and_,or_,itemgetter
    INF = 10**18
    mod1 = 10**9+7
    mod2 = 998244353
    
    #DecimalならPython
    #再帰ならPython!!!!!!!!!!!!!!!!!!!!!!!!!!
    
    
    '''
    大丈夫なところは全部行ける
    全部行けるけど、行かなくていい場所、いってはいけない場所もある
    いや、組み合わせ的に全部行かないとダメっぽい
    いや、行かなくてよいときもあるな
    制約的には各Kにおいて結構大胆な探索ができそう
    '''
    
    N,K = map(int, input().split())
    A = list(map(int, input().split()))
    
    st = set()
    for i in range(K):
        st.add(A[i])
    
    if N in st:
        print('No')
        exit()
    
    if N > 10**5:
        f = True
        for i in range(K):
            if A[i]+3 in st or A[i]+1 in st or A[i]+5 in st:
                f = False
        
        if f:
            print('Yes')
        else:
            print('No')
    
    else:
        dp = [0]*(N+1)
        for i in range(K):
            dp[A[i]] = 1
        for i in reversed(range(1,N+1)):
            if dp[i] == 1:
                if i >= 4 and dp[i-1] == 1:
                    dp[i-4] = 1
                if i >= 5 and dp[i-3] == 1:
                    dp[i-5] = 1
                if i >= 6 and dp[i-5] == 1:
                    dp[i-6] = 1
        
        if dp[1] == 1:
            print('No')
        else:
            print('Yes')
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
if __name__ == '__main__':
    main()
0