結果

問題 No.818 Dinner time
ユーザー RyutaroYamauchiRyutaroYamauchi
提出日時 2019-04-25 17:20:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 530 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 24,680 KB
最終ジャッジ日時 2024-04-30 21:58:00
合計ジャッジ時間 4,699 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
17,696 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 32 ms
10,752 KB
testcase_03 AC 30 ms
10,752 KB
testcase_04 AC 30 ms
10,752 KB
testcase_05 AC 31 ms
10,752 KB
testcase_06 AC 29 ms
10,752 KB
testcase_07 AC 30 ms
10,752 KB
testcase_08 AC 29 ms
10,752 KB
testcase_09 WA -
testcase_10 AC 30 ms
10,752 KB
testcase_11 WA -
testcase_12 AC 34 ms
10,752 KB
testcase_13 AC 37 ms
10,752 KB
testcase_14 AC 37 ms
10,752 KB
testcase_15 AC 36 ms
10,752 KB
testcase_16 AC 35 ms
10,752 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

A = []
B = []

N, M = map(int, input().strip().split(' '))

for i in range(N):
    a, b = map(int, input().strip().split(' '))
    A.append(a)
    B.append(b)

ans = 0

for k in range(N+1):
    score = 0
    for i in range(k):
        score += max(A[i] * M,
                     A[i] * (M - 1) + B[i],
                     B[i])
    max_score = score
    for i in range(k, N):
        score += max(A[i], B[i])
        if score > max_score:
            max_score = score
    if max_score > ans:
        ans = max_score

print(ans)
0