結果

問題 No.1208 anti primenumber game
ユーザー LayCurseLayCurse
提出日時 2020-08-30 13:38:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 2,540 bytes
コンパイル時間 2,588 ms
コンパイル使用メモリ 209,228 KB
実行使用メモリ 10,144 KB
最終ジャッジ日時 2023-08-09 11:56:02
合計ジャッジ時間 4,994 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,404 KB
testcase_01 AC 3 ms
7,440 KB
testcase_02 AC 2 ms
7,404 KB
testcase_03 AC 2 ms
7,404 KB
testcase_04 AC 2 ms
7,400 KB
testcase_05 AC 3 ms
7,448 KB
testcase_06 AC 2 ms
7,420 KB
testcase_07 AC 2 ms
7,448 KB
testcase_08 AC 2 ms
7,568 KB
testcase_09 AC 2 ms
7,640 KB
testcase_10 AC 2 ms
7,660 KB
testcase_11 AC 2 ms
7,452 KB
testcase_12 AC 2 ms
7,420 KB
testcase_13 AC 2 ms
7,404 KB
testcase_14 AC 2 ms
7,500 KB
testcase_15 AC 6 ms
9,440 KB
testcase_16 AC 5 ms
9,540 KB
testcase_17 AC 6 ms
9,448 KB
testcase_18 AC 5 ms
9,556 KB
testcase_19 AC 6 ms
9,520 KB
testcase_20 AC 5 ms
9,452 KB
testcase_21 AC 6 ms
9,484 KB
testcase_22 AC 6 ms
9,444 KB
testcase_23 AC 6 ms
9,532 KB
testcase_24 AC 10 ms
10,140 KB
testcase_25 AC 10 ms
10,068 KB
testcase_26 AC 11 ms
10,048 KB
testcase_27 AC 11 ms
10,080 KB
testcase_28 AC 10 ms
10,076 KB
testcase_29 AC 10 ms
10,144 KB
testcase_30 AC 5 ms
9,436 KB
testcase_31 AC 6 ms
9,480 KB
testcase_32 AC 6 ms
9,472 KB
testcase_33 AC 6 ms
9,624 KB
testcase_34 AC 6 ms
9,436 KB
testcase_35 AC 5 ms
9,436 KB
testcase_36 AC 5 ms
9,096 KB
testcase_37 AC 5 ms
9,448 KB
testcase_38 AC 10 ms
10,144 KB
testcase_39 AC 10 ms
10,084 KB
testcase_40 AC 10 ms
10,064 KB
testcase_41 AC 6 ms
9,744 KB
testcase_42 AC 7 ms
9,616 KB
testcase_43 AC 7 ms
9,584 KB
testcase_44 AC 7 ms
9,620 KB
testcase_45 AC 7 ms
9,580 KB
testcase_46 AC 6 ms
9,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    my_putchar_unlocked(c[i]);
  }
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
int N;
long long M;
long long A[200000];
long long dp[2][200000+1];
int main(){
  int i;
  rd(N);
  rd(M);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  for(i=(N)-1;i>=(0);i--){
    dp[0][i] = 1 - M - dp[1][i+1];
    dp[1][i] = A[i] - M - dp[1][i+1];
    if(A[i] > 1){
      chmax(dp[1][i], A[i] - 1 - dp[0][i]);
    }
  }
  if(dp[1][0] > 0){
    wt_L("First");
    wt_L('\n');
  }
  else{
    wt_L("Second");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20200813-1 [beta]

// --- original code ---
// int N; ll M, A[2d5];
// ll dp[2][2d5+1];
// 
// {
//   rd(N,M,A(N));
// 
//   rrep(i,N){
//     dp[0][i] = 1 - M - dp[1][i+1];
//     dp[1][i] = A[i] - M - dp[1][i+1];
//     if(A[i] > 1) dp[1][i] >?= A[i] - 1 - dp[0][i];
//   }
// 
//   wt(if[dp[1][0] > 0, "First", "Second"]);
// }
0