結果

問題 No.1267 Stop and Coin Game
ユーザー furafura
提出日時 2020-10-23 22:32:12
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 573 bytes
コンパイル時間 2,055 ms
コンパイル使用メモリ 198,588 KB
実行使用メモリ 13,796 KB
最終ジャッジ日時 2023-09-28 16:38:51
合計ジャッジ時間 4,525 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,684 KB
testcase_01 AC 3 ms
5,796 KB
testcase_02 AC 2 ms
5,536 KB
testcase_03 AC 2 ms
5,600 KB
testcase_04 AC 2 ms
5,512 KB
testcase_05 AC 3 ms
5,676 KB
testcase_06 AC 2 ms
5,492 KB
testcase_07 AC 2 ms
5,492 KB
testcase_08 AC 10 ms
5,640 KB
testcase_09 AC 2 ms
5,492 KB
testcase_10 AC 84 ms
13,748 KB
testcase_11 AC 22 ms
8,124 KB
testcase_12 AC 5 ms
5,580 KB
testcase_13 AC 2 ms
5,576 KB
testcase_14 AC 2 ms
5,560 KB
testcase_15 AC 2 ms
5,640 KB
testcase_16 AC 90 ms
13,796 KB
testcase_17 AC 2 ms
5,472 KB
testcase_18 AC 2 ms
5,548 KB
testcase_19 AC 2 ms
5,484 KB
testcase_20 AC 2 ms
5,488 KB
testcase_21 AC 2 ms
5,680 KB
testcase_22 AC 2 ms
5,488 KB
testcase_23 AC 2 ms
5,468 KB
testcase_24 AC 36 ms
10,280 KB
testcase_25 AC 57 ms
10,612 KB
testcase_26 AC 2 ms
5,560 KB
testcase_27 AC 4 ms
5,624 KB
testcase_28 AC 3 ms
5,800 KB
testcase_29 AC 3 ms
5,544 KB
testcase_30 AC 69 ms
12,008 KB
testcase_31 AC 3 ms
5,564 KB
testcase_32 AC 10 ms
5,776 KB
testcase_33 AC 35 ms
9,656 KB
testcase_34 AC 55 ms
10,604 KB
testcase_35 AC 69 ms
11,956 KB
testcase_36 AC 2 ms
5,572 KB
testcase_37 AC 14 ms
5,724 KB
testcase_38 AC 76 ms
13,672 KB
testcase_39 AC 7 ms
5,676 KB
testcase_40 AC 3 ms
5,620 KB
testcase_41 AC 7 ms
5,880 KB
testcase_42 AC 2 ms
5,536 KB
testcase_43 AC 10 ms
5,856 KB
testcase_44 AC 69 ms
11,756 KB
testcase_45 AC 2 ms
5,464 KB
testcase_46 AC 2 ms
5,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int n;
lint v,a[20],sum[1<<20];

bool vis[1<<20],memo[1<<20];

bool dfs(int S){
	if(vis[S]) return memo[S];
	vis[S]=true;

	bool& res=memo[S];
	rep(i,n) if(~S>>i&1) {
		if(sum[S]+a[i]<=v && !dfs(S|1<<i)) return res=true;
	}
	return res=false;
}

int main(){
	scanf("%d%lld",&n,&v);
	rep(i,n) scanf("%lld",&a[i]);

	rep(S,1<<n) rep(i,n) if(S>>i&1) sum[S]+=a[i];
	if(sum[(1<<n)-1]<=v){
		puts("Draw");
		return 0;
	}

	puts(dfs(0)?"First":"Second");

	return 0;
}
0