結果
問題 | No.1208 anti primenumber game |
ユーザー |
![]() |
提出日時 | 2020-08-30 16:19:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 120 ms / 2,000 ms |
コード長 | 1,214 bytes |
コンパイル時間 | 1,528 ms |
コンパイル使用メモリ | 167,892 KB |
実行使用メモリ | 18,944 KB |
最終ジャッジ日時 | 2024-11-15 10:56:43 |
合計ジャッジ時間 | 5,221 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 44 |
ソースコード
#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; }