結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,092 KB
testcase_01 AC 4 ms
7,124 KB
testcase_02 AC 4 ms
7,080 KB
testcase_03 AC 4 ms
7,032 KB
testcase_04 AC 4 ms
7,128 KB
testcase_05 WA -
testcase_06 AC 3 ms
7,064 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 3 ms
7,144 KB
testcase_10 WA -
testcase_11 AC 15 ms
7,140 KB
testcase_12 AC 7 ms
7,264 KB
testcase_13 AC 3 ms
6,980 KB
testcase_14 WA -
testcase_15 AC 4 ms
7,204 KB
testcase_16 AC 55 ms
6,992 KB
testcase_17 AC 4 ms
6,964 KB
testcase_18 AC 4 ms
7,140 KB
testcase_19 AC 4 ms
7,148 KB
testcase_20 AC 3 ms
7,228 KB
testcase_21 AC 4 ms
7,012 KB
testcase_22 AC 4 ms
7,116 KB
testcase_23 AC 4 ms
7,128 KB
testcase_24 AC 6 ms
7,256 KB
testcase_25 AC 75 ms
7,068 KB
testcase_26 AC 4 ms
7,196 KB
testcase_27 WA -
testcase_28 AC 4 ms
7,064 KB
testcase_29 AC 4 ms
7,188 KB
testcase_30 WA -
testcase_31 AC 5 ms
6,988 KB
testcase_32 AC 4 ms
7,292 KB
testcase_33 WA -
testcase_34 AC 61 ms
7,088 KB
testcase_35 WA -
testcase_36 AC 3 ms
6,984 KB
testcase_37 AC 21 ms
7,028 KB
testcase_38 AC 66 ms
7,084 KB
testcase_39 AC 7 ms
6,988 KB
testcase_40 AC 4 ms
7,088 KB
testcase_41 AC 5 ms
6,964 KB
testcase_42 AC 4 ms
7,124 KB
testcase_43 AC 5 ms
7,196 KB
testcase_44 AC 4 ms
7,068 KB
testcase_45 AC 4 ms
7,032 KB
testcase_46 AC 4 ms
7,084 KB
権限があれば一括ダウンロードができます

ソースコード

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(lint bit,vector<lint>& a){
    lint sm=0;
    if(memo[bit]!=2)return memo[bit]==1;
    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);
        }
    }
    if(flag)memo[bit]=1;
    else memo[bit]=0;
    
    return flag;
}
signed main(){
    cin>>n;
    cin>>v;
    vector<lint> a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    lint status=0;
    
    lint sm=0;
    rep(i,n)sm+=a[i];
    if(sm<=v){
        cout<<"Draw"<<"\n";
        return 0;
    }
    bool flag=rec(status,a);
	if(flag){
        cout<<"First"<<endl;
    }
    else{
        cout<<"Second"<<endl;
    }
    return 0;
}
0