結果
問題 |
No.1267 Stop and Coin Game
|
ユーザー |
![]() |
提出日時 | 2023-09-09 12:15:59 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 160 ms / 2,000 ms |
コード長 | 797 bytes |
コンパイル時間 | 5,170 ms |
コンパイル使用メモリ | 308,048 KB |
実行使用メモリ | 19,712 KB |
最終ジャッジ日時 | 2024-06-27 05:21:11 |
合計ジャッジ時間 | 7,736 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 |
ソースコード
#include<bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; using mint=modint998244353; //1000000007; using ll=long long; using pp=pair<ll,ll>; #define sr string #define vc vector #define fi first #define se second #define rep(i,n) for(ll i=0;i<(ll)n;i++) #define pb push_back #define all(v) v.begin(),v.end() #define pque priority_queue #define bpc(a) __builtin_popcount(a) int main(){ ll n,x;cin>>n>>x; vc<ll>v(n); rep(i,n)cin>>v[i]; ll b=1<<n; vc<ll>dp(b,0); vc<ll>r(b,x); rep(i,b)rep(j,n)if(i>>j&1)r[i]-=v[j]; if(r[b-1]>=0){ cout<<"Draw"; return 0; } rep(i,b)if(r[i]<0)dp[i]=1; for(int i=b-1;i>=0;i--)if(r[i]>=0){ rep(j,n)if(~i>>j&1){ if(dp[i|1<<j]==0)dp[i]=1; } } if(dp[0])cout<<"First"; else cout<<"Second"; }