結果

問題 No.818 Dinner time
ユーザー shotoyooshotoyoo
提出日時 2021-07-22 16:09:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 609 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 87,060 KB
実行使用メモリ 88,192 KB
最終ジャッジ日時 2023-09-24 14:11:50
合計ジャッジ時間 5,510 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,184 KB
testcase_01 AC 72 ms
71,160 KB
testcase_02 AC 72 ms
71,140 KB
testcase_03 AC 73 ms
71,416 KB
testcase_04 AC 73 ms
71,184 KB
testcase_05 AC 73 ms
71,288 KB
testcase_06 AC 75 ms
71,308 KB
testcase_07 AC 72 ms
71,356 KB
testcase_08 AC 72 ms
71,240 KB
testcase_09 WA -
testcase_10 AC 72 ms
71,260 KB
testcase_11 WA -
testcase_12 AC 73 ms
71,176 KB
testcase_13 AC 72 ms
71,180 KB
testcase_14 AC 75 ms
70,984 KB
testcase_15 AC 76 ms
71,356 KB
testcase_16 AC 76 ms
71,292 KB
testcase_17 AC 159 ms
88,120 KB
testcase_18 AC 137 ms
83,508 KB
testcase_19 AC 135 ms
83,640 KB
testcase_20 AC 157 ms
87,432 KB
testcase_21 AC 147 ms
85,852 KB
testcase_22 AC 140 ms
83,404 KB
testcase_23 AC 150 ms
85,348 KB
testcase_24 AC 169 ms
88,192 KB
testcase_25 AC 148 ms
84,948 KB
testcase_26 AC 140 ms
83,600 KB
testcase_27 AC 158 ms
86,128 KB
testcase_28 AC 152 ms
85,908 KB
testcase_29 AC 165 ms
88,072 KB
testcase_30 AC 156 ms
85,972 KB
testcase_31 AC 155 ms
85,960 KB
testcase_32 AC 145 ms
85,556 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 = 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