結果

問題 No.1208 anti primenumber game
ユーザー 沙耶花沙耶花
提出日時 2020-08-30 13:42:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 932 bytes
コンパイル時間 2,061 ms
コンパイル使用メモリ 207,140 KB
実行使用メモリ 34,712 KB
最終ジャッジ日時 2024-04-27 07:04:03
合計ジャッジ時間 5,407 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 52 ms
34,504 KB
testcase_16 AC 51 ms
34,708 KB
testcase_17 AC 52 ms
34,560 KB
testcase_18 AC 51 ms
34,580 KB
testcase_19 AC 52 ms
34,560 KB
testcase_20 AC 52 ms
34,580 KB
testcase_21 AC 55 ms
34,572 KB
testcase_22 AC 54 ms
34,504 KB
testcase_23 AC 53 ms
34,712 KB
testcase_24 AC 67 ms
34,592 KB
testcase_25 AC 68 ms
34,616 KB
testcase_26 AC 67 ms
34,404 KB
testcase_27 AC 66 ms
34,548 KB
testcase_28 AC 69 ms
34,604 KB
testcase_29 AC 67 ms
34,552 KB
testcase_30 AC 57 ms
34,640 KB
testcase_31 AC 55 ms
34,648 KB
testcase_32 AC 54 ms
34,576 KB
testcase_33 AC 55 ms
34,560 KB
testcase_34 AC 54 ms
34,684 KB
testcase_35 AC 53 ms
34,612 KB
testcase_36 AC 42 ms
27,776 KB
testcase_37 AC 53 ms
34,532 KB
testcase_38 AC 64 ms
34,616 KB
testcase_39 AC 62 ms
34,576 KB
testcase_40 AC 67 ms
34,544 KB
testcase_41 AC 54 ms
34,700 KB
testcase_42 AC 56 ms
34,536 KB
testcase_43 AC 56 ms
34,532 KB
testcase_44 AC 56 ms
34,584 KB
testcase_45 AC 55 ms
34,572 KB
testcase_46 AC 49 ms
31,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 2000000000000000000
vector<long long> A;
long long M;
int N;
long long get(int now,int t){
	if(now==N)return 0LL;
	static vector<vector<long long>> dp(A.size(),vector<long long>(2,-Inf));
	if(dp[now][t]!=-Inf)return dp[now][t];
	
	if(t==0){
		long long X = get(now+1,t^1) + A[now] - M;
		long long Y;
		if(A[now]!=1)Y = get(now+1,t) + (A[now]-1) - (1LL-M);
		else Y = -Inf;
		dp[now][t] = max(X,Y);
	}
	else{
		long long X = get(now+1,t^1) - A[now] + M;
		long long Y;
		if(A[now]!=1)Y = get(now+1,t) - (A[now]-1) + (1LL-M);
		else Y = Inf;
		dp[now][t] = min(X,Y);
	}
	return dp[now][t];
}

int main(){
	
	
	cin>>N;
	
	
	cin>>M;
	
	A.resize(N);
	for(int i=0;i<N;i++)scanf("%lld",&A[i]);
	
	long long ans = get(0,0);
	if(ans<=0)cout<<"Second"<<endl;
	else cout<<"First"<<endl;
	
	return 0;
}
0