結果

問題 No.1267 Stop and Coin Game
ユーザー chocoruskchocorusk
提出日時 2020-10-25 02:18:34
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 1,486 bytes
コンパイル時間 1,214 ms
コンパイル使用メモリ 126,156 KB
実行使用メモリ 12,860 KB
最終ジャッジ日時 2023-09-28 22:09:29
合計ジャッジ時間 3,968 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
12,484 KB
testcase_01 AC 4 ms
11,852 KB
testcase_02 AC 6 ms
12,568 KB
testcase_03 AC 4 ms
12,564 KB
testcase_04 AC 4 ms
12,564 KB
testcase_05 AC 5 ms
12,488 KB
testcase_06 AC 4 ms
12,768 KB
testcase_07 AC 5 ms
12,548 KB
testcase_08 AC 12 ms
12,588 KB
testcase_09 AC 5 ms
12,584 KB
testcase_10 AC 91 ms
12,860 KB
testcase_11 AC 28 ms
12,472 KB
testcase_12 AC 8 ms
12,496 KB
testcase_13 AC 6 ms
12,808 KB
testcase_14 AC 4 ms
12,548 KB
testcase_15 AC 5 ms
12,496 KB
testcase_16 AC 109 ms
12,568 KB
testcase_17 AC 5 ms
12,860 KB
testcase_18 AC 5 ms
12,488 KB
testcase_19 AC 5 ms
11,548 KB
testcase_20 AC 5 ms
12,720 KB
testcase_21 AC 5 ms
12,616 KB
testcase_22 AC 6 ms
12,492 KB
testcase_23 AC 5 ms
12,652 KB
testcase_24 AC 38 ms
12,544 KB
testcase_25 AC 64 ms
12,624 KB
testcase_26 AC 4 ms
11,980 KB
testcase_27 AC 7 ms
12,724 KB
testcase_28 AC 7 ms
11,476 KB
testcase_29 AC 6 ms
12,560 KB
testcase_30 AC 72 ms
12,772 KB
testcase_31 AC 6 ms
12,632 KB
testcase_32 AC 12 ms
12,628 KB
testcase_33 AC 37 ms
12,552 KB
testcase_34 AC 58 ms
12,576 KB
testcase_35 AC 71 ms
12,628 KB
testcase_36 AC 5 ms
11,612 KB
testcase_37 AC 18 ms
12,720 KB
testcase_38 AC 111 ms
12,548 KB
testcase_39 AC 11 ms
12,684 KB
testcase_40 AC 5 ms
12,008 KB
testcase_41 AC 12 ms
12,548 KB
testcase_42 AC 5 ms
11,540 KB
testcase_43 AC 19 ms
12,544 KB
testcase_44 AC 70 ms
11,864 KB
testcase_45 AC 5 ms
11,528 KB
testcase_46 AC 4 ms
12,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
using ll=long long;
typedef pair<int, int> P;

int main()
{
    int n; ll v;
    cin>>n>>v;
    ll a[20];
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    ll s[1<<20]={};
    for(int i=0; i<(1<<n); i++){
        for(int j=0; j<n; j++){
            if(i&(1<<j)) s[i]+=a[j];
        }
    }
    if(s[(1<<n)-1]<=v){
        cout<<"Draw"<<endl;
        return 0;
    }
    bool dp[1<<20]={};
    for(int i=(1<<n)-1; i>=0; i--){
        if(s[i]>v){
            continue;
        }
        bool dame=1;
        for(int j=0; j<n; j++){
            if(i&(1<<j)) continue;
            if(s[i^(1<<j)]<=v){
                dame=0;break;
            }
        }
        if(dame){
            dp[i]=0; continue;
        }
        for(int j=0; j<n; j++){
            if(i&(1<<j)) continue;
            if(s[i^(1<<j)]>v) continue;
            if(!dp[i^(1<<j)]){
                dp[i]=1; break;
            }
        }
    }
    if(dp[0]) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
    return 0;
}
0