結果
| 問題 | No.1267 Stop and Coin Game |
| コンテスト | |
| ユーザー |
applejam
|
| 提出日時 | 2025-12-21 16:33:40 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 102 ms / 2,000 ms |
| コード長 | 1,413 bytes |
| 記録 | |
| コンパイル時間 | 6,205 ms |
| コンパイル使用メモリ | 334,004 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-12-21 16:33:50 |
| 合計ジャッジ時間 | 8,661 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 43 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using mint = modint998244353;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vmi = vector<mint>;
using vvmi = vector<vmi>;
using vvvmi = vector<vvmi>;
#define all(a) (a).begin(), (a).end()
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
void solve(){
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n; ll v; cin >> n >> v;
ll s = 0;
vll a(n); rep(i, n){
cin >> a[i];
s += a[i];
}
if(s <= v){
cout << "Draw" << endl;
return 0;
}
vector<bool> dp((1<<n));
dp[0] = true;
rep2(i, 1, 1<<n){
bitset<20> bs(i);
ll tmp = 0;
bool f = true;
rep(j, n){
if(!bs[j]){
tmp += a[j];
}else{
bs.reset(j);
f = f && dp[bs.to_ulong()];
bs.set(j);
}
}
if(tmp > v){
dp[i] = true;
continue;
}
dp[i] = !f;
}
cout << (dp[(1<<n)-1] ? "First" : "Second") << endl;
return 0;
}
applejam