結果

問題 No.1267 Stop and Coin Game
ユーザー tonyu0
提出日時 2020-10-24 00:42:53
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 837 bytes
コンパイル時間 1,415 ms
コンパイル使用メモリ 124,148 KB
最終ジャッジ日時 2025-01-15 14:47:38
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 27 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (n); ++i)
#define rrep(i, j, n) for (int i = (n)-1; j <= i; --i)

int main() {
  ll n, v;
  cin >> n >> v;
  vector<ll> a(n);
  ll s = 0;
  rep(i, 0, n) {
    cin >> a[i];
    s += a[i];
  }

  if (s <= v) {
    cout << "Draw" << endl;
    return 0;
  }
  sort(a.begin(), a.end());

  unordered_map<ll, bool> mp;
  rep(S, 1, 1 << n) {
    ll t = 0;
    int u = __builtin_popcount(S);
    rep(i, 0, n) if (S >> i & 1) t += a[i];
    if (u & 1) mp[t] = true;
  }
  if (mp[v])
    cout << "First" << endl;
  else
    cout << "Second" << endl;

  return 0;
}
0