結果

問題 No.1267 Stop and Coin Game
ユーザー ShibuyapShibuyap
提出日時 2020-10-23 22:23:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 981 bytes
コンパイル時間 2,112 ms
コンパイル使用メモリ 198,176 KB
実行使用メモリ 7,756 KB
最終ジャッジ日時 2023-09-28 16:19:51
合計ジャッジ時間 4,179 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,588 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 4 ms
7,460 KB
testcase_03 AC 4 ms
7,444 KB
testcase_04 AC 4 ms
7,444 KB
testcase_05 AC 4 ms
7,644 KB
testcase_06 AC 4 ms
7,516 KB
testcase_07 AC 4 ms
7,484 KB
testcase_08 AC 4 ms
7,444 KB
testcase_09 AC 4 ms
7,644 KB
testcase_10 AC 24 ms
7,508 KB
testcase_11 AC 8 ms
7,500 KB
testcase_12 AC 6 ms
7,444 KB
testcase_13 AC 4 ms
7,508 KB
testcase_14 AC 4 ms
7,500 KB
testcase_15 AC 4 ms
7,616 KB
testcase_16 AC 32 ms
7,444 KB
testcase_17 AC 4 ms
7,500 KB
testcase_18 AC 4 ms
7,588 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 4 ms
7,440 KB
testcase_21 AC 4 ms
7,504 KB
testcase_22 AC 4 ms
7,512 KB
testcase_23 AC 4 ms
7,500 KB
testcase_24 AC 4 ms
7,564 KB
testcase_25 AC 43 ms
7,508 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 4 ms
7,440 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 4 ms
7,512 KB
testcase_30 AC 4 ms
7,520 KB
testcase_31 AC 4 ms
7,460 KB
testcase_32 AC 3 ms
7,504 KB
testcase_33 AC 4 ms
7,464 KB
testcase_34 AC 34 ms
7,452 KB
testcase_35 AC 4 ms
7,512 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 11 ms
7,616 KB
testcase_38 AC 13 ms
7,612 KB
testcase_39 AC 7 ms
7,452 KB
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 6 ms
7,464 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 5 ms
7,484 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 3 ms
7,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("First");}else{puts("Second");}
#define MAX_N 200005

int dp[1<<20];
ll n, v;
ll a[30];

int dfs(int x){
    if(dp[x] != -1) return dp[x];
    dp[x] = 0;

    ll sum = 0;
    bitset<20> bi(x);
    rep(i,n){
        if(bi[i]){
            sum += a[i];
        }
    }

    rep(i,n){
        if(bi[i] == 0 && sum + a[i] <= v){
            if(dfs(x+(1<<i)) == 0){
                dp[x] = 1;
                break;
            }
        }
    }

    return dp[x];
}

int main() {
    cin >> n >> v;
    rep(i,n) cin >> a[i];

    ll sum = 0;
    rep(i,n) sum += a[i];
    if(sum <= v){
        cout << "Draw" << endl;
        return 0;
    }

    rep(i,1<<20){
        dp[i] = -1;
    }

    if(dfs(0))yn;

    return 0;
}
 
 
0