結果

問題 No.561 東京と京都
ユーザー toshiro_yanagitoshiro_yanagi
提出日時 2022-07-22 01:14:35
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 675 bytes
コンパイル時間 4,823 ms
コンパイル使用メモリ 67,656 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-16 08:41:58
合計ジャッジ時間 5,978 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import strutils, sequtils


proc nextStr(): string =
  while not stdin.endOfFile:
    let c = stdin.readChar
    if c == '\r': continue
    if c in [' ', '\n']: break
    result.add(c)


proc main(): void =
  let
    n, d = parseInt(nextStr())
  var
    a = newSeqWith[n+1, [0, 0]]
    ans, p = 0

  for i in 0..<n:
    let t, k = parseInt(nextStr())
    a[i] = [t, k]

  for i in 0..<n:
    let
      noMove = a[i][p] + a[i+1][p]
      move1 = a[i][(p+1) mod 2] + a[i+1][(p+1) mod 2] - d
      move2 = a[i][(p+1) mod 2] + a[i+1][p] - 2*d
    if noMove < move1 or noMove < move2:
      p = (p+1) mod 2
      ans -= d
    ans += a[i][p]
  echo ans


when isMainModule: main()
0