結果

問題 No.1267 Stop and Coin Game
ユーザー publflpublfl
提出日時 2020-10-23 22:58:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 778 bytes
コンパイル時間 181 ms
コンパイル使用メモリ 32,016 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-28 17:28:18
合計ジャッジ時間 4,196 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 72 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int a;
long long int b;
long long int x[110];
long long int sum[2000010];
int func(int bit)
{
	if(bit+1==(1<<a))
	{
		if(sum[bit]<b) return 2;
		else return 3;
	}
	//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 1;
	else if(count[2]>0) return 2;
	return 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