結果
問題 | No.818 Dinner time |
ユーザー |
|
提出日時 | 2021-07-22 16:29:33 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 131 ms / 2,000 ms |
コード長 | 647 bytes |
コンパイル時間 | 144 ms |
コンパイル使用メモリ | 82,240 KB |
実行使用メモリ | 87,756 KB |
最終ジャッジ日時 | 2024-07-17 14:56:07 |
合計ジャッジ時間 | 3,823 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 29 |
ソースコード
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(2*10**5+10) write = lambda x: sys.stdout.write(x+"\n") debug = lambda x: sys.stderr.write(x+"\n") writef = lambda x: print("{:.12f}".format(x)) n,m = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(n)] v0 = [max(a,b) for a,b in ab] v1 = [max(m*a, (m-1)*a+b, b) for a,b in ab] cummax = -float("inf") cum0 = 0 cum1 = 0 ans = -float("inf") for j in range(n): cum0 += v0[j] cum1 += v1[j] if j>=0: cummax = max(cummax, -cum0 + cum1) ans = max(ans, cum0 + cummax) # print(cum0, cummax, ans) print(ans)