結果

問題 No.1852 Divide or Reduce
ユーザー tnakao0123tnakao0123
提出日時 2022-02-27 23:02:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 773 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 41,608 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 03:06:52
合計ジャッジ時間 6,553 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 67 ms
4,380 KB
testcase_02 AC 67 ms
4,376 KB
testcase_03 AC 68 ms
4,376 KB
testcase_04 AC 67 ms
4,380 KB
testcase_05 AC 67 ms
4,376 KB
testcase_06 AC 64 ms
4,376 KB
testcase_07 AC 65 ms
4,380 KB
testcase_08 AC 66 ms
4,376 KB
testcase_09 AC 66 ms
4,380 KB
testcase_10 AC 66 ms
4,376 KB
testcase_11 AC 66 ms
4,376 KB
testcase_12 AC 65 ms
4,380 KB
testcase_13 AC 65 ms
4,380 KB
testcase_14 AC 65 ms
4,380 KB
testcase_15 AC 65 ms
4,376 KB
testcase_16 AC 88 ms
4,376 KB
testcase_17 AC 88 ms
4,376 KB
testcase_18 AC 88 ms
4,376 KB
testcase_19 AC 59 ms
4,380 KB
testcase_20 AC 91 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1852.cc:  No.1852 Divide or Reduce - yukicoder
 */

#include<cstdio>
#include<algorithm>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

enum { First, Second };

/* typedef */

typedef long long ll;

/* global variables */

int as[MAX_N];

/* subroutines */

/* main */

int main() {
  int tn;
  scanf("%d", &tn);

  while (tn--) {
    int n;
    scanf("%d", &n);

    ll sum = 0;
    for (int i = 0; i < n; i++) scanf("%d", as + i), sum += as[i];

    int ans;
    if ((sum - n) & 1) ans = First;
    else {
      if (n & 1) ans = Second;
      else {
	int mina = *min_element(as, as + n);
	ans = (mina & 1) ? Second : First;
      }
    }

    if (ans == First) puts("First");
    else puts("Second");
  }

  return 0;
}
0