結果

問題 No.1267 Stop and Coin Game
ユーザー chocono2230chocono2230
提出日時 2020-10-23 23:56:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,373 bytes
コンパイル時間 2,159 ms
コンパイル使用メモリ 204,820 KB
実行使用メモリ 7,512 KB
最終ジャッジ日時 2023-09-28 19:16:12
合計ジャッジ時間 4,807 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
4,376 KB
testcase_10 WA -
testcase_11 AC 29 ms
4,380 KB
testcase_12 WA -
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 119 ms
7,276 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 39 ms
5,152 KB
testcase_25 WA -
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 4 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 68 ms
7,208 KB
testcase_31 WA -
testcase_32 AC 10 ms
4,384 KB
testcase_33 AC 37 ms
5,084 KB
testcase_34 AC 65 ms
5,136 KB
testcase_35 AC 68 ms
7,124 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 WA -
testcase_38 AC 126 ms
7,132 KB
testcase_39 AC 10 ms
4,380 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 11 ms
4,380 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 WA -
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 1 ms
4,376 KB
testcase_46 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  ll n, v;
  cin >> n >> v;
  vector<ll> a(n);
  ll sum = 0;
  rep(i, n){
    cin >> a.at(i);
    sum += a.at(i);
  }
  if(sum <= v){
    cout << "Draw" << endl;
    return 0;
  }
  vector<bool> b(1 << n);
  rep(bit, 1 << n){
    ll add = 0;
    rep(i, n){
      if((bit & (1 << i)) != 0){
        add += a.at(i);
      }
    }
    if(add > v) b.at(bit) = true;
    else b.at(bit) = false;
  }
  vector<int> dp(1 << n, -1);
  rrep(bit, (1 << n)){
    if(b.at(bit) == false){
      bool f = false;
      rep(i, n){
        if((bit & (1 << i)) == 0){
          int nx = bit + (1 << i);
          if(b.at(nx) == false){
            f = true;
          }
        }
      }
      if(f == false){
        dp.at(bit) = 0;//必敗
      }else{
        dp.at(bit) = 1;
      }
    }
  }
  if(dp.front() == 0) cout << "Second" << endl;
  else cout << "First" << endl;
  return 0;
}
0