結果
問題 | No.1267 Stop and Coin Game |
ユーザー |
|
提出日時 | 2021-05-18 15:09:43 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,573 ms / 2,000 ms |
コード長 | 996 bytes |
コンパイル時間 | 455 ms |
コンパイル使用メモリ | 82,348 KB |
実行使用メモリ | 98,560 KB |
最終ジャッジ日時 | 2024-10-08 15:17:01 |
合計ジャッジ時間 | 18,827 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 |
ソースコード
#region Header#!/usr/bin/env python3# from typing import *import sysimport ioimport mathimport collectionsimport decimalimport itertoolsimport bisectimport heapqdef input():return sys.stdin.readline()[:-1]# sys.setrecursionlimit(1000000)#endregion# _INPUT = """3 5# 5 1 1# """# sys.stdin = io.StringIO(_INPUT)def main():N, V = map(int, input().split())A = list(map(int, input().split()))if sum(A) <= V:print('Draw')returndp = [None] * (1<<N)for s in range(1<<N):cap = sum(A[i] for i in range(N) if s & (1<<i))dp[s] = (cap <= V)for s in reversed(range(1<<N)):if dp[s]:# 自分が何を選んでも、次に相手は勝つ。ということは、自分は負けif any(dp[s | (1<<j)] for j in range(N) if s & (1<<j) == 0):dp[s] = Falseif dp[0]:print('Second')else:print('First')if __name__ == '__main__':main()