結果

問題 No.1267 Stop and Coin Game
ユーザー chocoruskchocorusk
提出日時 2020-10-25 02:16:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,446 bytes
コンパイル時間 3,726 ms
コンパイル使用メモリ 126,760 KB
実行使用メモリ 12,768 KB
最終ジャッジ日時 2023-09-28 22:09:23
合計ジャッジ時間 5,173 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
12,564 KB
testcase_01 AC 4 ms
11,876 KB
testcase_02 AC 5 ms
12,552 KB
testcase_03 AC 5 ms
12,492 KB
testcase_04 AC 6 ms
12,768 KB
testcase_05 AC 6 ms
12,568 KB
testcase_06 AC 5 ms
12,608 KB
testcase_07 AC 4 ms
12,724 KB
testcase_08 AC 12 ms
12,556 KB
testcase_09 AC 5 ms
12,552 KB
testcase_10 AC 83 ms
12,532 KB
testcase_11 AC 25 ms
12,552 KB
testcase_12 AC 9 ms
12,560 KB
testcase_13 AC 5 ms
12,560 KB
testcase_14 AC 5 ms
12,624 KB
testcase_15 WA -
testcase_16 AC 96 ms
12,488 KB
testcase_17 AC 5 ms
12,544 KB
testcase_18 AC 5 ms
12,624 KB
testcase_19 AC 4 ms
11,604 KB
testcase_20 AC 4 ms
12,472 KB
testcase_21 AC 5 ms
12,488 KB
testcase_22 AC 5 ms
12,544 KB
testcase_23 AC 5 ms
12,584 KB
testcase_24 AC 38 ms
12,764 KB
testcase_25 WA -
testcase_26 AC 4 ms
11,452 KB
testcase_27 AC 7 ms
12,568 KB
testcase_28 AC 5 ms
11,468 KB
testcase_29 AC 5 ms
12,552 KB
testcase_30 AC 72 ms
12,488 KB
testcase_31 WA -
testcase_32 AC 12 ms
12,572 KB
testcase_33 AC 37 ms
12,484 KB
testcase_34 AC 51 ms
12,532 KB
testcase_35 AC 73 ms
12,768 KB
testcase_36 AC 5 ms
11,608 KB
testcase_37 WA -
testcase_38 AC 97 ms
12,768 KB
testcase_39 AC 11 ms
12,488 KB
testcase_40 AC 5 ms
11,668 KB
testcase_41 AC 11 ms
12,624 KB
testcase_42 AC 5 ms
12,312 KB
testcase_43 AC 17 ms
12,492 KB
testcase_44 AC 70 ms
11,528 KB
testcase_45 AC 4 ms
11,764 KB
testcase_46 AC 5 ms
12,584 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(!dp[i^(1<<j)]){
                dp[i]=1; break;
            }
        }
    }
    if(dp[0]) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
    return 0;
}
0