結果
問題 | No.1267 Stop and Coin Game |
ユーザー |
![]() |
提出日時 | 2025-03-24 06:38:08 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 701 bytes |
コンパイル時間 | 376 ms |
コンパイル使用メモリ | 82,580 KB |
実行使用メモリ | 91,552 KB |
最終ジャッジ日時 | 2025-03-24 06:38:18 |
合計ジャッジ時間 | 8,405 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 TLE * 1 -- * 12 |
ソースコード
N, V = map(int, input().split()) A = list(map(int, input().split())) try: import pypyjit pypyjit.set_param('max_unroll_recursion=-1') except ModuleNotFoundError: pass memo = {} def f(v, used) -> bool: k = (v << 20) | used # if (v, used) in memo: return memo[v, used] if k in memo: return memo[k] win = False for i in range(N): if used & (1 << i): continue if v - A[i] < 0: continue nu = used | (1 << i) win = not f(v - A[i], nu) if win: return True # memo[v, used] = win memo[k] = win return win if sum(A) <= V: print('Draw') exit(0) win = f(V, 0) if win: print('First') else: print('Second')