結果

問題 No.1208 anti primenumber game
ユーザー m_tsubasam_tsubasa
提出日時 2020-08-30 13:54:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 748 bytes
コンパイル時間 2,300 ms
コンパイル使用メモリ 206,760 KB
実行使用メモリ 15,928 KB
最終ジャッジ日時 2023-08-09 12:04:46
合計ジャッジ時間 6,117 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,384 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 47 ms
15,700 KB
testcase_16 AC 48 ms
15,920 KB
testcase_17 AC 47 ms
15,644 KB
testcase_18 AC 47 ms
15,548 KB
testcase_19 AC 47 ms
15,756 KB
testcase_20 AC 47 ms
15,616 KB
testcase_21 AC 48 ms
15,684 KB
testcase_22 AC 48 ms
15,648 KB
testcase_23 AC 47 ms
15,660 KB
testcase_24 AC 115 ms
15,640 KB
testcase_25 AC 112 ms
15,680 KB
testcase_26 AC 109 ms
15,636 KB
testcase_27 AC 110 ms
15,636 KB
testcase_28 AC 110 ms
15,928 KB
testcase_29 AC 108 ms
15,688 KB
testcase_30 AC 46 ms
15,640 KB
testcase_31 AC 46 ms
15,596 KB
testcase_32 AC 47 ms
15,920 KB
testcase_33 AC 45 ms
15,532 KB
testcase_34 AC 47 ms
15,696 KB
testcase_35 AC 45 ms
15,596 KB
testcase_36 AC 37 ms
12,928 KB
testcase_37 AC 47 ms
15,708 KB
testcase_38 AC 91 ms
15,520 KB
testcase_39 AC 92 ms
15,860 KB
testcase_40 AC 107 ms
15,660 KB
testcase_41 AC 50 ms
15,584 KB
testcase_42 AC 52 ms
15,668 KB
testcase_43 AC 51 ms
15,532 KB
testcase_44 AC 53 ms
15,708 KB
testcase_45 AC 53 ms
15,596 KB
testcase_46 AC 43 ms
14,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

long long n, m;
vector<vector<long long>> dp;
vector<long long> a;

int main() {
  cin >> n >> m;
  a.resize(n);
  for (auto &p : a) cin >> p;
  reverse(a.begin(), a.end());
  dp.assign(n, vector<long long>(2, 0));
  dp[0][0] = a[0] - 2 + m;
  dp[0][1] = a[0] - m;
  for (int i = 1; i < n; ++i) {
    long long manum = dp[i - 1][1], minum = dp[i - 1][1];
    if (a[i - 1] != 1) {
      manum = max(manum, dp[i - 1][0]);
      minum = min(minum, dp[i - 1][0]);
    }
    // 0
    dp[i][0] = manum + a[i] - 2 + m;
    // 1
    dp[i][1] = -manum + a[i] - m;
  }
  if ((dp[n - 1][0] > 0 && a[n - 1] != 1) || dp[n - 1][1] > 0)
    cout << "First" << endl;
  else
    cout << "Second" << endl;
  return 0;
}
0