結果

問題 No.1852 Divide or Reduce
ユーザー MitarushiMitarushi
提出日時 2022-02-24 23:16:11
言語 Nim
(2.0.2)
結果
AC  
実行時間 514 ms / 2,000 ms
コード長 1,007 bytes
コンパイル時間 7,288 ms
コンパイル使用メモリ 68,952 KB
実行使用メモリ 27,848 KB
最終ジャッジ日時 2023-09-15 10:25:14
合計ジャッジ時間 15,255 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 153 ms
4,380 KB
testcase_02 AC 153 ms
4,380 KB
testcase_03 AC 153 ms
4,380 KB
testcase_04 AC 153 ms
4,384 KB
testcase_05 AC 153 ms
4,384 KB
testcase_06 AC 120 ms
20,360 KB
testcase_07 AC 124 ms
25,840 KB
testcase_08 AC 123 ms
23,636 KB
testcase_09 AC 121 ms
19,912 KB
testcase_10 AC 124 ms
23,580 KB
testcase_11 AC 130 ms
27,848 KB
testcase_12 AC 132 ms
27,712 KB
testcase_13 AC 135 ms
27,088 KB
testcase_14 AC 134 ms
27,680 KB
testcase_15 AC 134 ms
27,328 KB
testcase_16 AC 514 ms
22,668 KB
testcase_17 AC 514 ms
22,256 KB
testcase_18 AC 507 ms
22,732 KB
testcase_19 AC 465 ms
24,396 KB
testcase_20 AC 511 ms
22,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils, sequtils

var n_sum = 0

proc solve() =
    let n = stdin.readLine.parseInt
    let a = stdin.readLine.split.map parseBiggestInt

    n_sum += n

    assert 1 <= n and n <= 200000
    assert a.mapIt(1 <= it and it <= 1000000000).foldl(a and b)

    let a_sum = a.foldl(a + b)

    if a.contains(1):
        if (a_sum - n) mod 2 == 0:
            echo "Second"
        else:
            echo "First"
    else:
        if (a_sum - (n + 1)) mod 2 == 0:
            echo "First"
        else:
            if n mod 2 == 1:
                echo "Second"
            else:
                let a_min = a.min
                if a_min mod 2 == 0:
                    echo "First"
                else:
                    echo "Second"

proc last_check() =
    try:
        let x = stdin.readLine
        assert x == ""
    except EOFError:
        return

let t = stdin.readLine.parseInt
assert 1 <= t and t <= 200000
for _ in 0..<t:
    solve()

assert 1 <= n_sum and n_sum <= 500000

last_check()
0