結果

問題 No.1267 Stop and Coin Game
ユーザー auauaauaua
提出日時 2020-10-23 22:51:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 222 ms / 2,000 ms
コード長 1,325 bytes
コンパイル時間 1,463 ms
コンパイル使用メモリ 166,720 KB
実行使用メモリ 11,324 KB
最終ジャッジ日時 2023-09-28 17:19:20
合計ジャッジ時間 4,368 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
11,212 KB
testcase_01 AC 5 ms
11,176 KB
testcase_02 AC 5 ms
11,188 KB
testcase_03 AC 5 ms
11,196 KB
testcase_04 AC 4 ms
11,076 KB
testcase_05 AC 4 ms
11,068 KB
testcase_06 AC 5 ms
11,180 KB
testcase_07 AC 4 ms
11,200 KB
testcase_08 AC 7 ms
11,128 KB
testcase_09 AC 5 ms
11,256 KB
testcase_10 AC 67 ms
11,196 KB
testcase_11 AC 29 ms
11,200 KB
testcase_12 AC 9 ms
11,280 KB
testcase_13 AC 5 ms
11,252 KB
testcase_14 AC 5 ms
11,132 KB
testcase_15 AC 5 ms
11,140 KB
testcase_16 AC 138 ms
11,184 KB
testcase_17 AC 5 ms
11,032 KB
testcase_18 AC 5 ms
11,324 KB
testcase_19 AC 4 ms
11,136 KB
testcase_20 AC 4 ms
11,032 KB
testcase_21 AC 5 ms
11,300 KB
testcase_22 AC 5 ms
11,300 KB
testcase_23 AC 5 ms
11,144 KB
testcase_24 AC 11 ms
11,084 KB
testcase_25 AC 81 ms
11,180 KB
testcase_26 AC 5 ms
11,272 KB
testcase_27 AC 4 ms
11,192 KB
testcase_28 AC 7 ms
11,192 KB
testcase_29 AC 5 ms
11,196 KB
testcase_30 AC 6 ms
11,080 KB
testcase_31 AC 5 ms
10,232 KB
testcase_32 AC 5 ms
11,320 KB
testcase_33 AC 5 ms
11,036 KB
testcase_34 AC 65 ms
11,196 KB
testcase_35 AC 5 ms
11,216 KB
testcase_36 AC 5 ms
11,136 KB
testcase_37 AC 21 ms
11,248 KB
testcase_38 AC 149 ms
11,292 KB
testcase_39 AC 12 ms
11,084 KB
testcase_40 AC 7 ms
11,144 KB
testcase_41 AC 13 ms
11,276 KB
testcase_42 AC 5 ms
11,180 KB
testcase_43 AC 22 ms
11,136 KB
testcase_44 AC 222 ms
11,088 KB
testcase_45 AC 5 ms
11,076 KB
testcase_46 AC 5 ms
11,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll INF=1e9+7;
const ll inf=INF*INF;
const ll MOD=1e9+7;
const ll mod=MOD;
const int MAX=200010;

vector<ll>a(20);
vector<ll>dp(1LL<<20,-1);
ll n;
ll v;
bool solve(ll i){
    if(dp[i]>=0)return dp[i];
    ll sum=0;
    rep(j,n){
        if((1LL<<j)&i){
            sum+=a[j];
        }
    }
    if(sum>v){
        dp[i]=1;
        return 1;
    }
    ll cnt=0;
    rep(j,n){
        if(((1LL<<j)&i)==0){
            cnt+=1-solve(i+(1LL<<j));
        }
    }
    if(cnt){
        dp[i]=1;
        return 1;
    }else{
        dp[i]=0;
        return 0;
    }
}

signed main(){
    cin>>n>>v;
    ll sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    ll ans=solve(0);
    if(sum<=v){
        cout<<"Draw"<<endl;
    }else if(ans){
        cout<<"First"<<endl;
    }else{
        cout<<"Second"<<endl;
    }
}
0