結果
| 問題 | No.1267 Stop and Coin Game |
| コンテスト | |
| ユーザー |
どらら
|
| 提出日時 | 2020-10-24 00:03:03 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,005 bytes |
| 記録 | |
| コンパイル時間 | 1,874 ms |
| コンパイル使用メモリ | 180,692 KB |
| 実行使用メモリ | 37,120 KB |
| 最終ジャッジ日時 | 2024-07-21 14:03:37 |
| 合計ジャッジ時間 | 10,100 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 TLE * 3 -- * 8 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
int N;
ll V;
vector<ll> v;
map<pair<ll,int>,bool> memo;
bool canwin(ll remain, int used){
if(remain < 0) return true;
if(memo.count(make_pair(remain,used)) > 0) return memo[make_pair(remain,used)];
bool ret = false;
rep(i,N){
if((used>>i)&1) continue;
if(!canwin(remain-v[i], used | (1<<i))){
ret = true;
}
}
return memo[make_pair(remain,used)] = ret;
}
int main(){
cin >> N >> V;
ll sum = 0;
rep(i,N){
ll a;
cin >> a;
v.push_back(a);
sum += a;
}
if(V >= sum){
cout << "Draw" << endl;
return 0;
}
sort(ALLOF(v));
reverse(ALLOF(v));
if(canwin(V, 0)) cout << "First" << endl;
else cout << "Second" << endl;
return 0;
}
どらら