結果

問題 No.1267 Stop and Coin Game
ユーザー simansiman
提出日時 2021-09-24 18:48:03
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 940 bytes
コンパイル時間 4,678 ms
コンパイル使用メモリ 103,164 KB
実行使用メモリ 7,712 KB
最終ジャッジ日時 2023-09-18 20:18:11
合計ジャッジ時間 3,955 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,600 KB
testcase_01 AC 3 ms
7,584 KB
testcase_02 AC 4 ms
7,628 KB
testcase_03 AC 4 ms
7,556 KB
testcase_04 AC 4 ms
7,560 KB
testcase_05 AC 3 ms
7,608 KB
testcase_06 AC 4 ms
7,628 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 4 ms
7,512 KB
testcase_10 WA -
testcase_11 AC 4 ms
7,548 KB
testcase_12 WA -
testcase_13 AC 3 ms
7,584 KB
testcase_14 AC 3 ms
7,608 KB
testcase_15 AC 4 ms
7,648 KB
testcase_16 AC 4 ms
7,676 KB
testcase_17 WA -
testcase_18 AC 3 ms
7,608 KB
testcase_19 AC 3 ms
7,612 KB
testcase_20 WA -
testcase_21 AC 3 ms
7,604 KB
testcase_22 AC 4 ms
7,608 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 4 ms
7,552 KB
testcase_26 AC 3 ms
7,600 KB
testcase_27 WA -
testcase_28 AC 4 ms
7,588 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 4 ms
7,592 KB
testcase_32 AC 3 ms
7,612 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 4 ms
7,552 KB
testcase_37 AC 4 ms
7,648 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 4 ms
7,600 KB
testcase_41 WA -
testcase_42 AC 3 ms
7,644 KB
testcase_43 AC 4 ms
7,588 KB
testcase_44 AC 4 ms
7,504 KB
testcase_45 AC 3 ms
7,612 KB
testcase_46 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

const int MAX_N = 20;

int memo[1 << 20];
ll A[MAX_N];
ll N, V;

int dfs(int n, ll sum, int mask) {
  if (sum > N) {
    return n % 2 == 0;
  }
  if (memo[mask] != -1) return memo[mask];

  int res = 0;
  for (int i = 0; i < N; ++i) {
    if (mask >> i & 1) continue;

    int nmask = mask | (1 << i);
    res |= dfs(n + 1, sum + A[i], nmask);
  }

  return memo[mask] = res;
}

int main() {
  memset(memo, -1, sizeof(memo));
  cin >> N >> V;

  ll sum = 0;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    sum += A[i];
  }

  if (sum <= V) {
    cout << "Draw" << endl;
  } else  if (dfs(0, 0, 0)) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }

  return 0;
}
0