結果

問題 No.818 Dinner time
コンテスト
ユーザー ikd
提出日時 2019-04-19 22:04:36
言語 Nim
(2.2.8)
コンパイル:
nim --nimcache=~ --hints:off -o:a.out -d:release cpp _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 511 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,695 ms
コンパイル使用メモリ 70,184 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2026-03-23 02:42:13
合計ジャッジ時間 4,511 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 4 WA * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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