結果
問題 | No.1852 Divide or Reduce |
ユーザー |
|
提出日時 | 2022-02-24 23:16:11 |
言語 | Nim (2.2.0) |
結果 |
AC
|
実行時間 | 504 ms / 2,000 ms |
コード長 | 1,007 bytes |
コンパイル時間 | 4,240 ms |
コンパイル使用メモリ | 66,012 KB |
実行使用メモリ | 23,784 KB |
最終ジャッジ日時 | 2024-07-02 14:14:19 |
合計ジャッジ時間 | 12,217 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 20 |
ソースコード
import strutils, sequtilsvar n_sum = 0proc solve() =let n = stdin.readLine.parseIntlet a = stdin.readLine.split.map parseBiggestIntn_sum += nassert 1 <= n and n <= 200000assert 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.minif a_min mod 2 == 0:echo "First"else:echo "Second"proc last_check() =try:let x = stdin.readLineassert x == ""except EOFError:returnlet t = stdin.readLine.parseIntassert 1 <= t and t <= 200000for _ in 0..<t:solve()assert 1 <= n_sum and n_sum <= 500000last_check()