結果
| 問題 | No.1267 Stop and Coin Game |
| コンテスト | |
| ユーザー |
yamake
|
| 提出日時 | 2020-10-23 23:13:28 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,301 bytes |
| コンパイル時間 | 802 ms |
| コンパイル使用メモリ | 82,968 KB |
| 実行使用メモリ | 14,392 KB |
| 最終ジャッジ日時 | 2024-07-21 13:03:52 |
| 合計ジャッジ時間 | 4,479 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 3 WA * 3 TLE * 1 -- * 36 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define debug(output) cout<<#output<<"= "<<output<<endl
using lint=long long;
int MOD=1000000007;
vector<int> memo((1ll<<20),2);
lint n,v;
bool rec(int bit,vector<lint>& a,int cur){
lint sm=0;
if(memo[bit]!=2)return memo[bit];
rep(i,n){
if(bit&(1<<i))sm+=a[i];
}
if(sm>v){
memo[bit]=1;
return true;
}
rep(i,n){
if(!(bit&(1<<i))){
if(sm+a[i]>v){
memo[bit]=0;
return false;
}
}
else break;
}
bool flag=false;
rep(i,n){
if(!(bit&(1<<i))){
flag=flag||!rec(bit+(1<<i),a,cur+1);
}
}
return flag;
}
signed main(){
cin>>n;
cin>>v;
vector<lint> a(n);
rep(i,n)cin>>a[i];
sort(a.begin(),a.end());
int status=0;
bool flag=rec(status,a,0);
lint sm=0;
rep(i,n)sm+=a[i];
if(sm<=v){
cout<<"Draw"<<"\n";
return 0;
}
if(flag){
cout<<"First"<<endl;
}
else{
cout<<"Second"<<endl;
}
return 0;
}
yamake