結果

問題 No.1267 Stop and Coin Game
ユーザー chocopuuchocopuu
提出日時 2020-11-27 20:47:12
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,523 bytes
コンパイル時間 2,072 ms
コンパイル使用メモリ 202,344 KB
実行使用メモリ 20,040 KB
最終ジャッジ日時 2023-10-01 04:22:19
合計ジャッジ時間 4,995 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
13,580 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 6 ms
13,740 KB
testcase_03 AC 5 ms
13,580 KB
testcase_04 AC 5 ms
13,652 KB
testcase_05 AC 5 ms
13,840 KB
testcase_06 AC 5 ms
13,656 KB
testcase_07 AC 5 ms
13,616 KB
testcase_08 AC 14 ms
13,660 KB
testcase_09 AC 5 ms
13,644 KB
testcase_10 AC 123 ms
19,752 KB
testcase_11 AC 39 ms
15,612 KB
testcase_12 AC 9 ms
13,564 KB
testcase_13 AC 5 ms
13,584 KB
testcase_14 AC 5 ms
13,752 KB
testcase_15 AC 5 ms
13,584 KB
testcase_16 AC 194 ms
19,932 KB
testcase_17 AC 5 ms
13,876 KB
testcase_18 AC 6 ms
13,636 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 6 ms
13,640 KB
testcase_21 AC 5 ms
13,656 KB
testcase_22 AC 5 ms
13,648 KB
testcase_23 AC 5 ms
13,560 KB
testcase_24 AC 41 ms
17,692 KB
testcase_25 AC 111 ms
17,792 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 7 ms
13,584 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 5 ms
13,616 KB
testcase_30 AC 73 ms
20,036 KB
testcase_31 AC 6 ms
13,836 KB
testcase_32 AC 13 ms
13,660 KB
testcase_33 AC 39 ms
17,652 KB
testcase_34 AC 98 ms
17,752 KB
testcase_35 AC 73 ms
20,040 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 25 ms
13,840 KB
testcase_38 AC 206 ms
19,760 KB
testcase_39 AC 14 ms
13,584 KB
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 14 ms
13,652 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 23 ms
13,780 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 WA -
testcase_46 AC 5 ms
13,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
//#include "atcoder/all"
//using namespace atcoder;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;

int dp[1ll << 20];
int win[1ll << 20];
int N, V;
vector<int> a;

int dfs(int bit, int turn) {
	if(win[bit] != -1) return win[bit];
	int v = dp[bit];
	if(v > V) {
		return turn ^ 1;
	}
	int ret = 0;
	REP(i, N) {
		if(bit & (1ll << i)) continue;
		ret |= dfs(bit ^ (1ll << i), turn ^ 1) ^ turn;
	}
	return win[bit] = ret ^ turn;
}

signed main(){
	cin >> N >> V;
	a.resize(N);
	cin >> a;
	if(accumulate(ALL(a), 0ll) < V) {
		out("Draw");
		return 0;
	}
	REP(i, 1ll << N) {
		int sum = 0;
		REP(j, N) {
			if(i & (1ll << j)) sum += a[j];
		}
		dp[i] = sum;
	}
	memset(win, -1, sizeof(win));
	dfs(0, 0);
	if(win[0] == 1) {
		out("First");
	} else {
		out("Second");
	}
}
0