結果
| 問題 |
No.1267 Stop and Coin Game
|
| コンテスト | |
| ユーザー |
どらら
|
| 提出日時 | 2020-10-23 23:51:42 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 965 bytes |
| コンパイル時間 | 1,769 ms |
| コンパイル使用メモリ | 178,296 KB |
| 実行使用メモリ | 45,084 KB |
| 最終ジャッジ日時 | 2024-07-21 13:52:58 |
| 合計ジャッジ時間 | 14,407 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}
if(canwin(V, 0)) cout << "First" << endl;
else cout << "Second" << endl;
return 0;
}
どらら