結果

問題 No.761 平均値ゲーム
ユーザー ikdikd
提出日時 2018-12-09 10:22:12
言語 Nim
(2.2.0)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 499 bytes
コンパイル時間 3,482 ms
コンパイル使用メモリ 65,548 KB
実行使用メモリ 24,300 KB
最終ジャッジ日時 2024-07-01 05:48:04
合計ジャッジ時間 9,888 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils, sequtils

proc f(a: seq[int64], turn: bool): bool =
  let n = a.len
  if a.all(proc(x: int64): bool = a[0]==x):
    result = true
  else:
    let s = a.foldl(a+b)
    var j = 0
    while j<n and a[j]*n<s:
      j+=1
    let
      res1 = f(a[0..<j], not turn)
      res2 = f(a[j..<n], not turn)
    result = not (res1 and res2)

proc main() =
  let
    n = stdin.readLine.parseInt
    a = stdin.readLine.split.map(parseBiggestInt)
  echo if f(a, true): "First" else: "Second"
main()
0