結果

問題 No.818 Dinner time
ユーザー shotoyoo
提出日時 2021-07-22 16:09:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 609 bytes
コンパイル時間 213 ms
コンパイル使用メモリ 82,356 KB
実行使用メモリ 87,536 KB
最終ジャッジ日時 2024-07-17 14:55:19
合計ジャッジ時間 4,071 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 27 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

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 = 0
cum0 = 0
cum1 = 0
ans = -float("inf")
for j in range(n):
    cum0 += v0[j]
#     print(cum0, cummax)
    cum1 += v1[j]
    cummax = max(cummax, -cum0 + cum1)
    ans = max(ans, cum0 + cummax)
print(ans)
0