結果
| 問題 | No.1267 Stop and Coin Game |
| コンテスト | |
| ユーザー |
sotanishy
|
| 提出日時 | 2020-10-23 22:59:17 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 768 ms / 2,000 ms |
| コード長 | 419 bytes |
| 記録 | |
| コンパイル時間 | 220 ms |
| コンパイル使用メモリ | 85,264 KB |
| 実行使用メモリ | 90,156 KB |
| 最終ジャッジ日時 | 2026-04-03 04:38:46 |
| 合計ジャッジ時間 | 9,865 ms |
|
ジャッジサーバーID (参考情報) |
judge5_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 43 |
ソースコード
import sys
input = sys.stdin.readline
N, V = map(int, input().split())
A = list(map(int, input().split()))
if sum(A) <= V:
print('Draw')
exit()
dp = [False] * (1 << N)
for S in range(1 << N)[::-1]:
s = sum(A[i] for i in range(N) if S >> i & 1)
if s > V:
dp[S] = True
else:
dp[S] = any(not dp[S | 1 << i] for i in range(N) if not (S >> i & 1))
print('First' if dp[0] else 'Second')
sotanishy