結果
| 問題 |
No.1267 Stop and Coin Game
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-23 22:49:16 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,267 ms / 2,000 ms |
| コード長 | 659 bytes |
| コンパイル時間 | 199 ms |
| コンパイル使用メモリ | 82,280 KB |
| 実行使用メモリ | 84,608 KB |
| 最終ジャッジ日時 | 2024-07-21 11:52:33 |
| 合計ジャッジ時間 | 12,624 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 43 |
ソースコード
N, V = map(int, input().split())
A = list(map(int, input().split()))
a = sum(A)
if a <= V:
print('Draw')
exit()
DP = [0] * 2 ** N
from itertools import combinations
for i in range(0, N + 1):
for Iter in combinations(range(N), r=i):
x = sum([A[j] for j in Iter] + [0])
y = sum([2 ** j for j in Iter] + [0])
if a - x > V:
DP[y] = 1
else:
if any(DP[y - 2 ** j] == 0 for j in Iter):
DP[y] = 1
if DP[-1]:
print('First')
else:
print('Second')