結果
| 問題 |
No.1208 anti primenumber game
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-09-13 16:59:55 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 659 bytes |
| コンパイル時間 | 2,204 ms |
| コンパイル使用メモリ | 198,192 KB |
| 最終ジャッジ日時 | 2025-01-14 14:31:32 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 WA * 7 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | lint m; scanf("%d%lld",&n,&m);
| ~~~~~^~~~~~~~~~~~~~~~
main.cpp:17:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
17 | lint a; scanf("%lld",&a);
| ~~~~~^~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using lint=long long;
const long long INF=1LL<<61;
int main(){
int n;
lint m; scanf("%d%lld",&n,&m);
vector dp(n+1,vector(2,-INF));
dp[0][0]=0;
rep(i,n){
lint a; scanf("%lld",&a);
// 先手番
// 1 個残しで取る
if(a>1) dp[i+1][0]=max(dp[i+1][0],dp[i][0]+a-1+m);
// 全部取る
dp[i+1][1]=max(dp[i+1][1],dp[i][0]+a-m);
// 後手番
// 1 個残しで取る
if(a>1) dp[i+1][1]=max(dp[i+1][1],dp[i][1]-(a-1)-m);
// 全部取る
dp[i+1][0]=max(dp[i+1][0],dp[i][1]-a+m);
}
puts(max(dp[n][0],dp[n][1])>0?"First":"Second");
return 0;
}