結果
| 問題 |
No.1208 anti primenumber game
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2020-08-30 13:42:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 85 ms / 2,000 ms |
| コード長 | 932 bytes |
| コンパイル時間 | 2,401 ms |
| コンパイル使用メモリ | 197,648 KB |
| 最終ジャッジ日時 | 2025-01-13 21:20:07 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 44 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:40:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
40 | for(int i=0;i<N;i++)scanf("%lld",&A[i]);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#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;
}
沙耶花