結果

問題 No.1208 anti primenumber game
ユーザー auauaauaua
提出日時 2020-08-30 16:19:27
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 1,214 bytes
コンパイル時間 1,633 ms
コンパイル使用メモリ 166,580 KB
実行使用メモリ 18,736 KB
最終ジャッジ日時 2023-08-09 15:02:16
合計ジャッジ時間 6,758 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,080 KB
testcase_01 AC 3 ms
5,956 KB
testcase_02 AC 4 ms
6,068 KB
testcase_03 AC 4 ms
5,956 KB
testcase_04 AC 4 ms
5,952 KB
testcase_05 AC 4 ms
6,000 KB
testcase_06 AC 4 ms
5,956 KB
testcase_07 AC 4 ms
6,152 KB
testcase_08 AC 4 ms
6,260 KB
testcase_09 AC 4 ms
6,060 KB
testcase_10 AC 4 ms
6,136 KB
testcase_11 AC 4 ms
5,968 KB
testcase_12 AC 4 ms
5,952 KB
testcase_13 AC 4 ms
6,136 KB
testcase_14 AC 4 ms
6,192 KB
testcase_15 AC 41 ms
18,736 KB
testcase_16 AC 41 ms
18,588 KB
testcase_17 AC 41 ms
18,580 KB
testcase_18 AC 40 ms
18,544 KB
testcase_19 AC 39 ms
18,544 KB
testcase_20 AC 39 ms
18,584 KB
testcase_21 AC 43 ms
18,536 KB
testcase_22 AC 44 ms
18,680 KB
testcase_23 AC 41 ms
18,716 KB
testcase_24 AC 109 ms
18,584 KB
testcase_25 AC 110 ms
18,716 KB
testcase_26 AC 104 ms
18,536 KB
testcase_27 AC 102 ms
18,584 KB
testcase_28 AC 106 ms
18,540 KB
testcase_29 AC 103 ms
18,668 KB
testcase_30 AC 40 ms
18,668 KB
testcase_31 AC 40 ms
18,540 KB
testcase_32 AC 41 ms
18,536 KB
testcase_33 AC 43 ms
18,532 KB
testcase_34 AC 41 ms
18,540 KB
testcase_35 AC 41 ms
18,536 KB
testcase_36 AC 33 ms
16,072 KB
testcase_37 AC 41 ms
18,724 KB
testcase_38 AC 83 ms
18,544 KB
testcase_39 AC 87 ms
18,736 KB
testcase_40 AC 102 ms
18,680 KB
testcase_41 AC 48 ms
18,532 KB
testcase_42 AC 46 ms
18,584 KB
testcase_43 AC 47 ms
18,652 KB
testcase_44 AC 48 ms
18,724 KB
testcase_45 AC 48 ms
18,580 KB
testcase_46 AC 39 ms
17,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll inf=1e9+7;
const ll mod=1e9+7;
const int MAX=200010;

vector<ll>dp(MAX,-inf*inf);
vector<ll>a(MAX);
ll n,m;
ll solve(ll i){
    if(i==n-1){
        dp[i]=a[i]-m;
        if(a[i]>1)dp[i]=max(dp[i],a[i]-1-(1-m));
        return dp[i];
    }
    if(dp[i]>-inf*inf)return dp[i];
    ll res=a[i]-m-solve(i+1);
    if(a[i]>1){
        res=max(res,solve(i+1)+a[i]-1-(1-m));
    }
    if(a[i]>4){
        res=max(res,a[i]-4-max(4-m-solve(i+1),3+solve(i+1)-(1-m)));
    }
    dp[i]=res;
    return res;
}

signed main(){
    cin>>n>>m;
    rep(i,n){
        cin>>a[i];
    }
    ll ans=solve(0);
    rep(i,n){
        //cout<<i<<' '<<dp[i]<<endl;
    }
    if(ans>0)cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}
0