結果

問題 No.818 Dinner time
ユーザー maspymaspy
提出日時 2020-04-10 00:18:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 428 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 10,588 KB
実行使用メモリ 20,848 KB
最終ジャッジ日時 2023-10-12 03:26:08
合計ジャッジ時間 6,930 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
7,956 KB
testcase_01 AC 17 ms
7,844 KB
testcase_02 AC 17 ms
7,808 KB
testcase_03 AC 16 ms
7,796 KB
testcase_04 WA -
testcase_05 AC 16 ms
7,904 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 16 ms
7,720 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 16 ms
7,840 KB
testcase_15 AC 16 ms
7,832 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

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