結果

問題 No.1267 Stop and Coin Game
ユーザー yamakeyamake
提出日時 2020-10-23 23:13:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,301 bytes
コンパイル時間 791 ms
コンパイル使用メモリ 82,212 KB
実行使用メモリ 7,280 KB
最終ジャッジ日時 2023-09-28 18:23:49
合計ジャッジ時間 4,808 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,156 KB
testcase_01 AC 4 ms
7,160 KB
testcase_02 AC 4 ms
7,072 KB
testcase_03 AC 4 ms
7,192 KB
testcase_04 AC 4 ms
7,212 KB
testcase_05 WA -
testcase_06 AC 4 ms
7,124 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 4 ms
7,160 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0