結果

問題 No.1267 Stop and Coin Game
ユーザー publflpublfl
提出日時 2020-10-23 23:00:35
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 439 ms / 2,000 ms
コード長 840 bytes
コンパイル時間 376 ms
コンパイル使用メモリ 31,732 KB
実行使用メモリ 17,368 KB
最終ジャッジ日時 2023-09-28 17:31:09
合計ジャッジ時間 3,948 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,996 KB
testcase_01 AC 2 ms
4,988 KB
testcase_02 AC 2 ms
4,992 KB
testcase_03 AC 2 ms
4,996 KB
testcase_04 AC 2 ms
5,076 KB
testcase_05 AC 2 ms
5,036 KB
testcase_06 AC 2 ms
5,020 KB
testcase_07 AC 2 ms
5,060 KB
testcase_08 AC 5 ms
7,364 KB
testcase_09 AC 2 ms
5,000 KB
testcase_10 AC 152 ms
17,272 KB
testcase_11 AC 29 ms
8,116 KB
testcase_12 AC 6 ms
5,144 KB
testcase_13 AC 2 ms
5,028 KB
testcase_14 AC 2 ms
5,064 KB
testcase_15 AC 2 ms
4,960 KB
testcase_16 AC 258 ms
17,312 KB
testcase_17 AC 2 ms
5,012 KB
testcase_18 AC 2 ms
5,076 KB
testcase_19 AC 2 ms
5,000 KB
testcase_20 AC 2 ms
5,024 KB
testcase_21 AC 2 ms
5,052 KB
testcase_22 AC 2 ms
5,024 KB
testcase_23 AC 2 ms
4,988 KB
testcase_24 AC 34 ms
10,448 KB
testcase_25 AC 136 ms
11,156 KB
testcase_26 AC 3 ms
5,016 KB
testcase_27 AC 2 ms
5,004 KB
testcase_28 AC 4 ms
5,128 KB
testcase_29 AC 2 ms
4,996 KB
testcase_30 AC 62 ms
13,444 KB
testcase_31 AC 3 ms
5,100 KB
testcase_32 AC 4 ms
6,972 KB
testcase_33 AC 26 ms
9,064 KB
testcase_34 AC 111 ms
11,096 KB
testcase_35 AC 69 ms
13,276 KB
testcase_36 AC 3 ms
5,108 KB
testcase_37 AC 19 ms
7,480 KB
testcase_38 AC 283 ms
17,368 KB
testcase_39 AC 9 ms
7,296 KB
testcase_40 AC 4 ms
5,056 KB
testcase_41 AC 10 ms
7,312 KB
testcase_42 AC 2 ms
5,008 KB
testcase_43 AC 20 ms
7,480 KB
testcase_44 AC 439 ms
17,212 KB
testcase_45 AC 2 ms
5,012 KB
testcase_46 AC 2 ms
4,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int a;
long long int b;
long long int x[110];
long long int sum[2000010];
int check[2000010];
int func(int bit)
{
	if(bit+1==(1<<a))
	{
		return 2;
	}
	if(check[bit]) return check[bit];
	//1win 2draw 3lose
	int count[5]={};
	for(int i=1;i<=a;i++)
	{
		if((bit&(1<<(i-1)))==0)
		{
			int newBit = bit+(1<<(i-1));
			if(sum[newBit]<=b) count[func(newBit)]++;
		}
	}
	if(count[3]>0) return check[bit] = 1;
	else if(count[2]>0) return check[bit] = 2;
	return check[bit] = 3;
	
}
long long int C = 0;
void init(int k, int S)
{
	if(k>a)
	{
		sum[S] = C;
		return;
	}
	init(k+1,S);
	C += x[k];
	init(k+1,S+(1<<(k-1)));
	C -= x[k];
}
int main()
{
	scanf("%d%lld",&a,&b);
	for(int i=1;i<=a;i++) scanf("%lld",&x[i]);
	init(1,0);
	int k = func(0);
	if(k==1) printf("First");
	else if(k==2) printf("Draw");
	else printf("Second");
}
0