結果
問題 | No.1267 Stop and Coin Game |
ユーザー |
|
提出日時 | 2024-01-23 01:20:02 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,019 bytes |
コンパイル時間 | 251 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 84,096 KB |
最終ジャッジ日時 | 2024-09-28 06:33:43 |
合計ジャッジ時間 | 8,709 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 WA * 10 |
ソースコード
## https://yukicoder.me/problems/no/1267def main():N, V = map(int, input().split())A = list(map(int, input().split()))if V - sum(A) >= 0:print("Draw")returngrandies = [-1] * (1 << N)for bit in range(1 << N):b = (1 << N - 1) & (~bit)v = 0for i in range(N):if b & (1 << i):v += A[i]if V - v < 0:grandies[bit] = 0else:rest_v = V - vgrandy_set = set()for i in range(N):if bit & (1 << i):if rest_v - A[i] < 0:continuebit_ = bit - (1 << i)grandy_set.add(grandies[bit_])for i in range(N + 2):if i not in grandy_set:grandies[bit] = ibreakif grandies[1 << N - 1] == 0:print("Second")else:print("First")if __name__ == '__main__':main()