結果

問題 No.1208 anti primenumber game
ユーザー okok
提出日時 2020-08-30 16:09:25
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 1,725 bytes
コンパイル時間 903 ms
コンパイル使用メモリ 82,208 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2023-08-09 14:53:59
合計ジャッジ時間 3,867 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 16 ms
6,128 KB
testcase_16 AC 15 ms
6,268 KB
testcase_17 AC 16 ms
6,256 KB
testcase_18 AC 16 ms
6,248 KB
testcase_19 AC 16 ms
6,252 KB
testcase_20 AC 16 ms
6,132 KB
testcase_21 AC 17 ms
6,128 KB
testcase_22 AC 17 ms
6,180 KB
testcase_23 AC 19 ms
6,184 KB
testcase_24 AC 34 ms
6,180 KB
testcase_25 AC 33 ms
6,256 KB
testcase_26 AC 32 ms
6,140 KB
testcase_27 AC 31 ms
6,180 KB
testcase_28 AC 31 ms
6,192 KB
testcase_29 AC 31 ms
6,188 KB
testcase_30 AC 15 ms
6,120 KB
testcase_31 AC 16 ms
6,388 KB
testcase_32 AC 16 ms
6,180 KB
testcase_33 AC 17 ms
6,128 KB
testcase_34 AC 16 ms
6,252 KB
testcase_35 AC 15 ms
6,252 KB
testcase_36 AC 12 ms
5,396 KB
testcase_37 AC 16 ms
6,176 KB
testcase_38 AC 29 ms
6,132 KB
testcase_39 AC 28 ms
6,180 KB
testcase_40 AC 32 ms
6,120 KB
testcase_41 AC 18 ms
6,132 KB
testcase_42 AC 19 ms
6,244 KB
testcase_43 AC 18 ms
6,176 KB
testcase_44 AC 20 ms
6,140 KB
testcase_45 AC 20 ms
6,400 KB
testcase_46 AC 17 ms
5,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
#include<cassert>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)2e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
    int N, M;
    vector<int> A;
    vector<int> B;
	bool flag = true;
	int ans = 0;
	
    cin>>N>>M;
    
	// assert(M > 0);
	
	A.resize(N);
	B.resize(N+1);
	
    for(int i = 0; i < N; i++){
		cin>>A[i];
		
		if(A[i] == 1) B[i] = 1;
    }
	
	for(int i = N-2; i >= 0; i--){
		if(B[i+1] && B[i]) B[i] += B[i+1];
	}
	
	for(int i = 0; i < N; i++){
		if(A[i] == 1) {
			if(flag) {
				ans += (1 - M);
			} else {
				ans -= (1 - M);
			}
			
			flag = !flag;
			
		} else {
			if(B[i+1] + i + 1 == N) {
				if(flag) {
					ans += max((A[i] - M) +  (B[i+1]) / 2 * (1 - M) -  (B[i+1]+1) / 2 * (1 - M), 
					 (A[i] - 1) - (1 - M) - (B[i+1]) / 2 * (1 - M) +  (B[i+1]+1) / 2 * (1 - M));
					break;
				} else {
					ans -= max((A[i] - M) +  (B[i+1]) / 2 * (1 - M) -  (B[i+1]+1) / 2 * (1 - M), 
					 (A[i] - 1) - (1 - M) - (B[i+1]) / 2 * (1 - M) +  (B[i+1]+1) / 2 * (1 - M));
					break;
				}
			} else {
				
				if(B[i+1]%2) {
					if(flag) {
						ans += (A[i] - M);
					} else {
						ans -= (A[i] - M);
					}
					
					flag = !flag;
				} else {
					if(flag) {
						ans += (A[i] - 1);
						ans -= (1 - M);
					} else {
						ans -= (A[i] - 1);
						ans += (1 - M);
					}
				}
			
			}
		}
	}
	
	if(ans <= 0) cout<<"Second"<<endl;
	else cout<<"First"<<endl;
	 
	return 0;
}
0