結果

問題 No.451 575
ユーザー t8m8⛄️t8m8⛄️
提出日時 2016-12-02 07:14:07
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 906 bytes
コンパイル時間 3,309 ms
コンパイル使用メモリ 67,904 KB
実行使用メモリ 4,788 KB
最終ジャッジ日時 2023-09-12 08:03:22
合計ジャッジ時間 10,632 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 10 ms
4,380 KB
testcase_06 AC 14 ms
4,376 KB
testcase_07 AC 45 ms
4,696 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 170 ms
4,696 KB
testcase_14 AC 25 ms
4,380 KB
testcase_15 AC 36 ms
4,376 KB
testcase_16 AC 145 ms
4,380 KB
testcase_17 AC 269 ms
4,696 KB
testcase_18 AC 41 ms
4,604 KB
testcase_19 AC 44 ms
4,464 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 2 ms
4,384 KB
testcase_23 WA -
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 18) Warning: imported and not used: 'sequtils' [UnusedImport]

ソースコード

diff #

import strutils, sequtils, math

var a = newSeq[int64](100010)

proc f(i, n: int, b: seq[int64]): bool =
  if i > n: return true
  if i mod 2 == 0:
    a[i] = a[i-1] - b[i-1]
    if a[i] <= 0 or 10^18 < a[i]: return false
    return f(i+1, n, b)
  else:
    a[i] = b[i-1] - a[i-1]
    if a[i] <= 0 or 10^18 < a[i]: return false
    return f(i+1, n, b)

when isMainModule:
  var
    n = stdin.readLine.parseInt
    b = newSeq[int64](n)

  for i in 0..n-1:
    b[i] = stdin.readLine.parseBiggestInt


  var
    d: int64 = max(b[0] div 1000, 1)

  for i in 1..1000:
    var
      l: int64 = d*(i-1)
      u: int64 = d*i

    while u - l > 1:
      let m: int64 = (u + l) div 2
      a[0] = m
      if f(1, n, b): l = m
      else: u = m

    for i in max(1, l-100)..min(b[0]-1, u+100):
      a[0] = i
      if f(1, n, b):
        echo n+1
        for i in 0..n:
          echo a[i]
        quit()

  echo "-1"
0