結果

問題 No.818 Dinner time
ユーザー mkawa2mkawa2
提出日時 2022-03-09 15:09:54
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 987 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 86,924 KB
実行使用メモリ 93,576 KB
最終ジャッジ日時 2023-10-11 15:55:37
合計ジャッジ時間 5,906 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,340 KB
testcase_01 AC 74 ms
71,176 KB
testcase_02 AC 75 ms
71,036 KB
testcase_03 AC 75 ms
71,164 KB
testcase_04 AC 75 ms
71,412 KB
testcase_05 AC 74 ms
71,172 KB
testcase_06 AC 75 ms
71,344 KB
testcase_07 AC 73 ms
71,408 KB
testcase_08 AC 76 ms
71,428 KB
testcase_09 WA -
testcase_10 AC 75 ms
71,416 KB
testcase_11 WA -
testcase_12 AC 75 ms
71,252 KB
testcase_13 AC 73 ms
71,340 KB
testcase_14 AC 74 ms
71,360 KB
testcase_15 AC 74 ms
71,388 KB
testcase_16 AC 75 ms
71,348 KB
testcase_17 AC 160 ms
92,084 KB
testcase_18 AC 138 ms
86,736 KB
testcase_19 AC 141 ms
86,584 KB
testcase_20 AC 157 ms
90,996 KB
testcase_21 AC 149 ms
89,140 KB
testcase_22 AC 138 ms
86,004 KB
testcase_23 AC 142 ms
86,512 KB
testcase_24 AC 163 ms
93,576 KB
testcase_25 AC 139 ms
86,652 KB
testcase_26 AC 136 ms
86,140 KB
testcase_27 AC 153 ms
90,320 KB
testcase_28 AC 141 ms
87,232 KB
testcase_29 AC 158 ms
90,932 KB
testcase_30 AC 150 ms
89,696 KB
testcase_31 AC 154 ms
90,084 KB
testcase_32 AC 141 ms
87,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = (1 << 63)-1
inf = (1 << 31)-1
# md = 10**9+7
md = 998244353

n, m = LI()
ab = LLI(n)
cs = [0]
for a, b in ab:
    cs.append(cs[-1]+max(a*m, a*(m-1)+b, b))

s = 0
mn = 0
ans = cs[-1]
for i in range(n)[::-1]:
    a, b = ab[i]
    s += max(a, b)
    mn = min(mn, s)
    cur = cs[i]+s-mn
    if cur > ans: ans = cur

print(ans)
0