結果
| 問題 |
No.1267 Stop and Coin Game
|
| コンテスト | |
| ユーザー |
tpyneriver
|
| 提出日時 | 2020-10-23 22:50:48 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 529 ms / 2,000 ms |
| コード長 | 594 bytes |
| コンパイル時間 | 384 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 84,512 KB |
| 最終ジャッジ日時 | 2024-07-21 11:57:38 |
| 合計ジャッジ時間 | 7,689 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 43 |
ソースコード
import sys
readline = sys.stdin.readline
N, V = map(int, readline().split())
A = list(map(int, readline().split()))
if sum(A) <= V:
print('Draw')
else:
SA = sum(A)
dp = [0]*(1<<N)
dp[0] = 1
for S in range(1, 1<<N):
res = SA
R = [i for i in range(N) if S&(1<<i)]
for r in R:
res -= A[r]
if res > V:
dp[S] = 1
continue
ans = -1
for r in R:
if dp[S^(1<<r)] == -1:
ans = 1
dp[S] = ans
print('First' if dp[(1<<N)-1]== 1 else 'Second')
tpyneriver