結果

問題 No.1267 Stop and Coin Game
ユーザー kk
提出日時 2020-10-27 23:00:35
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 119 ms / 2,000 ms
コード長 921 bytes
コンパイル時間 2,018 ms
コンパイル使用メモリ 199,972 KB
実行使用メモリ 7,628 KB
最終ジャッジ日時 2023-09-29 03:28:15
合計ジャッジ時間 5,466 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,356 KB
testcase_01 AC 3 ms
7,348 KB
testcase_02 AC 3 ms
7,416 KB
testcase_03 AC 3 ms
7,416 KB
testcase_04 AC 4 ms
7,628 KB
testcase_05 AC 4 ms
7,416 KB
testcase_06 AC 4 ms
7,608 KB
testcase_07 AC 3 ms
7,420 KB
testcase_08 AC 6 ms
7,572 KB
testcase_09 AC 4 ms
7,404 KB
testcase_10 AC 62 ms
7,420 KB
testcase_11 AC 26 ms
7,508 KB
testcase_12 AC 7 ms
7,352 KB
testcase_13 AC 4 ms
7,548 KB
testcase_14 AC 4 ms
7,572 KB
testcase_15 AC 4 ms
7,424 KB
testcase_16 AC 112 ms
7,344 KB
testcase_17 AC 3 ms
7,340 KB
testcase_18 AC 4 ms
7,524 KB
testcase_19 AC 4 ms
7,512 KB
testcase_20 AC 4 ms
7,424 KB
testcase_21 AC 4 ms
7,460 KB
testcase_22 AC 4 ms
7,420 KB
testcase_23 AC 4 ms
7,532 KB
testcase_24 AC 10 ms
7,320 KB
testcase_25 AC 74 ms
7,344 KB
testcase_26 AC 4 ms
7,424 KB
testcase_27 AC 4 ms
7,432 KB
testcase_28 AC 4 ms
7,464 KB
testcase_29 AC 4 ms
7,576 KB
testcase_30 AC 5 ms
7,344 KB
testcase_31 AC 5 ms
7,444 KB
testcase_32 AC 4 ms
7,344 KB
testcase_33 AC 4 ms
7,464 KB
testcase_34 AC 61 ms
7,348 KB
testcase_35 AC 4 ms
7,568 KB
testcase_36 AC 4 ms
7,344 KB
testcase_37 AC 19 ms
7,552 KB
testcase_38 AC 119 ms
7,504 KB
testcase_39 AC 11 ms
7,516 KB
testcase_40 AC 4 ms
7,400 KB
testcase_41 AC 12 ms
7,416 KB
testcase_42 AC 4 ms
7,320 KB
testcase_43 AC 20 ms
7,528 KB
testcase_44 AC 4 ms
7,348 KB
testcase_45 AC 4 ms
7,408 KB
testcase_46 AC 4 ms
7,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++)
#define ALL(x) (x).begin(), (x).end()

const double PI = acos(-1);

int n;
long long v;
long long a[20];
int dp[1<<20];

bool dfs(int vis) {
  if (dp[vis] != -1)
    return dp[vis];

  long long acc = 0;
  REP (i, n) if (vis & 1 << i) acc += a[i];
  if (acc > v)
    return dp[vis] = true;

  bool ret = false;
  REP (i, n) {
    if (vis & 1 << i) continue;
    if (!dfs(vis | 1 << i))
      ret = true;
  }
  
  return dp[vis] = ret;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin >> n >> v;
  REP (i, n) cin >> a[i];
  memset(dp, -1, sizeof(dp));
  
  long long sum = 0;
  REP (i, n) sum += a[i];
  if (v >= sum)
    cout << "Draw" << endl;
  else if (dfs(0))
    cout << "First" << endl;
  else
    cout << "Second" << endl;
    
  return 0;
}
0