結果

問題 No.1208 anti primenumber game
ユーザー hedwig100
提出日時 2020-09-06 15:14:36
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 1,004 bytes
コンパイル時間 1,734 ms
コンパイル使用メモリ 168,460 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-29 07:13:07
合計ジャッジ時間 4,037 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 44
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N;
    ll M;
    cin >> N >> M;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    ll dp0 = 0,dp1 = 0,tot = 0;;
    irep(i,N) {
        tot += A[i] - M;
        ll new0,new1;
        if (A[i] > 1) {
            new0 = max(A[i] - M + dp1,A[i] - 1 + dp0);
            new1 = min(dp0,-M + dp1);
        } else {
            new0 = 1 - M + dp1;
            new1 = dp0;
        }
        swap(dp0,new0);
        swap(dp1,new1);
    }
    cout << (2*dp0 > tot ? "First" : "Second") << '\n';
    return 0;
}
0