結果

問題 No.1267 Stop and Coin Game
ユーザー tailstails
提出日時 2020-10-25 01:27:15
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 591 bytes
コンパイル時間 1,398 ms
コンパイル使用メモリ 30,976 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-21 16:51:47
合計ジャッジ時間 2,905 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:23:1: warning: return type defaults to 'int' [-Wimplicit-int]
   23 | main(){
      | ^~~~
main.c: In function 'main':
main.c:32:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration]
   32 |         write(1,s>v?f(0,v)>0?"First ":"Second":"Draw  ",6);
      |         ^~~~~
main.c:33:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration]
   33 |         _exit(0);
      |         ^~~~~
      |         _Exit

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

char*mmap();
#define RD(v) int v=0;{int c;while(c=*r++-48,c>=0)v=v*10+c;}
#define RDL(v) long v=0;{int c;while(c=*r++-48,c>=0)v=v*10+c;}

long a[20];
char g[1<<20];
int n;

int f(int m,long v){
	if(g[m]) return g[m];
	for(int i=0;i<n;++i){
		int k=m|1<<i;
		if(k!=m&&v-a[i]>=0&&f(k,v-a[i])<0){
			return g[m]=1;
		}
	}
	return g[m]=-1;
}

main(){
	char*r=mmap(0l,1024l,1,2,0,0ll);
	{RD(t); n=t;}
	RDL(v);

	long s=0;
	for(int i=0;i<n;++i){
		RDL(x); a[i]=x; s+=x;
	}
	write(1,s>v?f(0,v)>0?"First ":"Second":"Draw  ",6);
	_exit(0);
}
0