結果

問題 No.818 Dinner time
ユーザー ikd
提出日時 2019-04-19 22:04:36
言語 Nim
(2.2.0)
結果
WA  
実行時間 -
コード長 511 bytes
コンパイル時間 3,468 ms
コンパイル使用メモリ 67,016 KB
実行使用メモリ 11,648 KB
最終ジャッジ日時 2024-07-01 23:14:30
合計ジャッジ時間 6,016 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 4 WA * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 28) Warning: imported and not used: 'math' [UnusedImport]

ソースコード

diff #

import strutils, sequtils, math

proc main() =
  var
    nm = stdin.readLine.split.map(parseInt)
    (n, m) = (nm[0], nm[1])
    abi = (0..<n).mapIt(stdin.readLine.split.map(parseBiggestInt))
  
  var
    aacc = newSeq[int64]()
    bestAcc = newSeq[int64]()
  aacc.add(0)
  bestAcc.add(0)
  for ab in abi:
    aacc.add(aacc[^1] + ab[0])
    bestAcc.add(bestAcc[^1] + max(ab[0], ab[1]))
  var ans:int64 = 0
  if bestAcc.max > aacc.max:
    ans += bestAcc.max
    m -= 1
  ans += aacc.max * m
  echo ans
  
main()
0