結果
問題 | No.1267 Stop and Coin Game |
ユーザー |
|
提出日時 | 2022-02-19 16:14:52 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,010 bytes |
コンパイル時間 | 175 ms |
コンパイル使用メモリ | 82,512 KB |
実行使用メモリ | 92,416 KB |
最終ジャッジ日時 | 2024-06-29 10:27:00 |
合計ジャッジ時間 | 5,449 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 42 WA * 1 |
ソースコード
N,V = map(int,input().split())A = list(map(int,input().split()))S = sum(A)import sysif S < V:print("Draw")exit()sys.setrecursionlimit(10 ** 8 )dat = [0] * (1 << N)for bit in range(1,1 << N):for i in range(N):mask = 1 << iif bit & mask:dat[bit] = A[i] + dat[bit ^ mask]break"""from functools import lru_cache@lru_cachedef calc(S = 0):#flag = S.count('1')for i in range(N):mask = 1 << iif S & mask:continueif dat[S | mask] > V:continuea = calc(S | mask)if a == False:return Truereturn False"""grundy = [0] * (1 << N)for bit in range((1 << N)-1,-1,-1):flag = Falsefor i in range(N):mask = 1 << iif bit & mask:continueif dat[bit | mask] > V:continueif grundy[bit | mask] == 0:flag = Truebreakif flag:grundy[bit] = 1else:grundy[bit] = 0print('First' if grundy[0] else "Second")