結果

問題 No.1267 Stop and Coin Game
ユーザー ocvret_ocvret_
提出日時 2020-10-24 10:56:33
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 772 bytes
コンパイル時間 1,682 ms
コンパイル使用メモリ 168,528 KB
実行使用メモリ 11,384 KB
最終ジャッジ日時 2023-09-28 20:14:34
合計ジャッジ時間 5,256 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
11,188 KB
testcase_01 AC 5 ms
11,208 KB
testcase_02 AC 5 ms
11,040 KB
testcase_03 AC 5 ms
11,060 KB
testcase_04 AC 5 ms
11,040 KB
testcase_05 AC 5 ms
11,248 KB
testcase_06 AC 5 ms
11,268 KB
testcase_07 AC 5 ms
11,224 KB
testcase_08 AC 5 ms
11,260 KB
testcase_09 AC 5 ms
11,036 KB
testcase_10 AC 47 ms
11,156 KB
testcase_11 AC 25 ms
11,340 KB
testcase_12 AC 9 ms
11,240 KB
testcase_13 AC 5 ms
11,300 KB
testcase_14 AC 5 ms
11,264 KB
testcase_15 AC 5 ms
11,204 KB
testcase_16 AC 106 ms
11,252 KB
testcase_17 AC 5 ms
11,180 KB
testcase_18 AC 6 ms
11,244 KB
testcase_19 AC 5 ms
11,296 KB
testcase_20 AC 5 ms
11,176 KB
testcase_21 AC 5 ms
11,180 KB
testcase_22 AC 6 ms
11,040 KB
testcase_23 AC 5 ms
11,268 KB
testcase_24 AC 8 ms
11,264 KB
testcase_25 AC 85 ms
11,112 KB
testcase_26 AC 5 ms
11,228 KB
testcase_27 AC 5 ms
11,244 KB
testcase_28 AC 4 ms
10,124 KB
testcase_29 AC 5 ms
11,384 KB
testcase_30 AC 5 ms
11,040 KB
testcase_31 AC 6 ms
11,192 KB
testcase_32 AC 5 ms
10,224 KB
testcase_33 AC 5 ms
11,300 KB
testcase_34 AC 60 ms
11,092 KB
testcase_35 AC 5 ms
11,040 KB
testcase_36 AC 5 ms
11,184 KB
testcase_37 AC 20 ms
11,260 KB
testcase_38 AC 123 ms
11,168 KB
testcase_39 AC 13 ms
11,044 KB
testcase_40 AC 5 ms
11,056 KB
testcase_41 AC 13 ms
11,352 KB
testcase_42 AC 5 ms
11,060 KB
testcase_43 AC 23 ms
11,236 KB
testcase_44 AC 5 ms
11,092 KB
testcase_45 AC 5 ms
11,048 KB
testcase_46 AC 5 ms
11,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
//#include<atcoder/all>

using namespace std;
//using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

ll n,V;
vector<int> dp(1 << 21,-1);
bool dfs(vector<ll> &a,int msk){
  if(dp[msk] != -1)return dp[msk];
  ll sum = 0;
  rep(i,n)if(msk >> i & 1)sum += a[i];
  bool is = true;
  rep(i,n)if(!(msk >> i & 1) && sum+a[i] <= V)is &= dfs(a,msk | 1 << i);
  return dp[msk] = !is;
}

int main(){
  
  cin >> n >> V;
  vector<ll> a(n);
  ll s = 0;
  rep(i,n)cin >> a[i],s += a[i];
  if(s <= V){
    cout << "Draw\n";
    return 0;
  }
  cout << (dfs(a,0) ? "First\n" : "Second\n");
  


  return 0;
}
0