結果
問題 |
No.1267 Stop and Coin Game
|
ユーザー |
![]() |
提出日時 | 2025-02-03 22:01:34 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,181 ms / 2,000 ms |
コード長 | 660 bytes |
コンパイル時間 | 479 ms |
コンパイル使用メモリ | 82,704 KB |
実行使用メモリ | 143,256 KB |
最終ジャッジ日時 | 2025-02-03 22:01:46 |
合計ジャッジ時間 | 9,267 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 |
ソースコード
N,V = map(int,input().split()) A = list(map(int,input().split())) A.sort(reverse = True) if sum(A) <= V: print("Draw") exit() allb = (1<<N)-1 X = [0] * (allb + 1) for i in range(allb + 1): x = i ^ allb t1 = V for j in range(N): if x & (1<<j): t1 -= A[j] X[i] = t1 from functools import lru_cache @lru_cache(maxsize=1050000) def f(x): #if X[x] < 0: # return True for i in range(N): if x & (1<<i): if X[x] - A[i] < 0: continue if not(f(x ^ (1<<i))): return True return False if f(allb): print("First") else: print("Second")