結果
問題 | No.1267 Stop and Coin Game |
ユーザー |
|
提出日時 | 2020-10-24 00:59:48 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 584 ms / 2,000 ms |
コード長 | 460 bytes |
コンパイル時間 | 361 ms |
コンパイル使用メモリ | 81,952 KB |
実行使用メモリ | 92,196 KB |
最終ジャッジ日時 | 2024-07-21 14:36:46 |
合計ジャッジ時間 | 6,198 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 |
ソースコード
n, v = map(int, input().split()) a = list(map(int, input().split())) if sum(a) <= v: exit(print("Draw")) dp = [-1] * (1 << n) def dfs(S, t): if t > v: dp[S] = 0 return 0 if dp[S] != -1: return dp[S] res = 0 for i in range(n): if (1 << i) & S: continue res |= dfs((1 << i) | S, t + a[i]) dp[S] = (not res) return (not res) if dfs(0, 0): print("Second") else: print("First")