結果

問題 No.818 Dinner time
ユーザー maspy
提出日時 2020-04-10 00:18:25
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 428 bytes
コンパイル時間 133 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 23,468 KB
最終ジャッジ日時 2024-09-14 03:08:46
合計ジャッジ時間 6,558 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 4 WA * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, readline().split())
m = map(int, read().split())
AB = zip(m, m)

dp = [0, 0, 0]  # 0回、1回、M回
for a, b in AB:
    newdp = [0, 0, 0]
    newdp[0] = max(dp)
    newdp[1] = max(dp[1:]) + max(a, b)
    full = a * (M - 1) + max(a, b)
    newdp[2] = dp[2] + full
    dp = newdp
print(max(dp))
0