結果

問題 No.818 Dinner time
ユーザー tpynerivertpyneriver
提出日時 2019-04-22 12:09:51
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 375 ms / 2,000 ms
コード長 392 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 10,868 KB
実行使用メモリ 33,592 KB
最終ジャッジ日時 2023-08-20 00:59:44
合計ジャッジ時間 6,636 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,108 KB
testcase_01 AC 16 ms
8,152 KB
testcase_02 AC 17 ms
8,276 KB
testcase_03 AC 16 ms
8,132 KB
testcase_04 AC 16 ms
8,284 KB
testcase_05 AC 16 ms
8,232 KB
testcase_06 AC 16 ms
8,120 KB
testcase_07 AC 15 ms
8,136 KB
testcase_08 AC 16 ms
8,252 KB
testcase_09 AC 16 ms
8,252 KB
testcase_10 AC 16 ms
8,124 KB
testcase_11 AC 15 ms
8,216 KB
testcase_12 AC 16 ms
8,316 KB
testcase_13 AC 16 ms
8,240 KB
testcase_14 AC 17 ms
8,304 KB
testcase_15 AC 16 ms
8,232 KB
testcase_16 AC 16 ms
8,236 KB
testcase_17 AC 357 ms
33,368 KB
testcase_18 AC 236 ms
24,136 KB
testcase_19 AC 245 ms
24,660 KB
testcase_20 AC 327 ms
30,792 KB
testcase_21 AC 281 ms
27,432 KB
testcase_22 AC 227 ms
22,996 KB
testcase_23 AC 261 ms
25,608 KB
testcase_24 AC 375 ms
33,592 KB
testcase_25 AC 256 ms
25,500 KB
testcase_26 AC 216 ms
22,512 KB
testcase_27 AC 323 ms
30,344 KB
testcase_28 AC 266 ms
26,092 KB
testcase_29 AC 346 ms
32,108 KB
testcase_30 AC 300 ms
28,348 KB
testcase_31 AC 319 ms
29,720 KB
testcase_32 AC 265 ms
26,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate
N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
K1 = [max(t) for t in AB]
K3 = list(accumulate(K1))
ks = sum(K1)
K1 = [0] + list(accumulate(K1[::-1]))
K1 = list(accumulate(K1, min))[::-1][1:]
K2 = [max(a*M, a*(M-1)+b, b) for (a, b) in AB]
K2 = list(accumulate(K2))
print(max(j-i+ks-k for i, j, k in zip(K1, K2, K3)))
0