結果

問題 No.818 Dinner time
ユーザー shotoyooshotoyoo
提出日時 2021-07-22 16:29:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 647 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 87,172 KB
実行使用メモリ 88,220 KB
最終ジャッジ日時 2023-09-24 14:12:53
合計ジャッジ時間 5,704 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,512 KB
testcase_01 AC 75 ms
71,364 KB
testcase_02 AC 74 ms
71,376 KB
testcase_03 AC 73 ms
71,536 KB
testcase_04 AC 74 ms
71,560 KB
testcase_05 AC 73 ms
71,348 KB
testcase_06 AC 74 ms
71,284 KB
testcase_07 AC 74 ms
71,044 KB
testcase_08 AC 74 ms
71,400 KB
testcase_09 AC 75 ms
71,256 KB
testcase_10 AC 72 ms
71,352 KB
testcase_11 AC 74 ms
71,296 KB
testcase_12 AC 73 ms
71,368 KB
testcase_13 AC 75 ms
71,332 KB
testcase_14 AC 74 ms
71,360 KB
testcase_15 AC 74 ms
71,288 KB
testcase_16 AC 73 ms
71,228 KB
testcase_17 AC 160 ms
88,220 KB
testcase_18 AC 139 ms
83,788 KB
testcase_19 AC 139 ms
83,772 KB
testcase_20 AC 159 ms
87,748 KB
testcase_21 AC 147 ms
85,824 KB
testcase_22 AC 140 ms
83,488 KB
testcase_23 AC 149 ms
85,412 KB
testcase_24 AC 170 ms
88,144 KB
testcase_25 AC 149 ms
85,276 KB
testcase_26 AC 142 ms
83,336 KB
testcase_27 AC 157 ms
86,200 KB
testcase_28 AC 151 ms
85,660 KB
testcase_29 AC 166 ms
88,024 KB
testcase_30 AC 158 ms
85,840 KB
testcase_31 AC 160 ms
86,044 KB
testcase_32 AC 149 ms
85,716 KB
権限があれば一括ダウンロードができます

ソースコード

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 = -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)
0