結果

問題 No.2852 Yakitori Optimization Problem
ユーザー stunniitastunniita
提出日時 2024-08-25 15:04:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,438 bytes
コンパイル時間 226 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 36,160 KB
最終ジャッジ日時 2024-08-25 15:04:52
合計ジャッジ時間 7,387 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

# DP[0][0] = A[0] + C[0]  # 0本目をタレ


# print(f"{DP=}")

# for k in range(1, K + 1):
#     for n in range(1, N):
#         # print(f"{k=}, {n=}")

#         tare = (DP[k][n - 1] + A[n] + C[n]) if DP[k][n - 1] != 0 else 0
#         sio = (DP[k - 1][n - 1] + A[n] + B[n]) if DP[k - 1][n - 1] != 0 else 0

#         # print(f"{A + C[n]=}, {tare=}")
#         # print(f"{A + B[n]=}, {sio=}")

#         DP[k][n] = max(tare, sio)

# print(f"{DP=}")

# print(DP[K][N - 1])


TARE = [0] * N
TARE[0] = A[0] + C[0]  # 0本目をタレ

# 全部タレ使用の初期値
for i in range(1, N):
    TARE[i] = TARE[i - 1] + (A[i] + C[i])

# print(f"{TARE=}")


SIO = [0] * N
SIO[0] = A[0] + B[0]  # 0本目を塩

# print(f"{SIO=}")

for k in range(1, K + 1):
    for n in range(1, N):
        # print(f"{k=}, {n=}")

        n_is_tare = (SIO[n - 1] + A[n] + C[n]) if SIO[n - 1] != 0 else 0
        n_is_sio = (TARE[n - 1] + A[n] + B[n]) if TARE[n - 1] != 0 else 0

        # print(f"{A[n] + C[n]=}, {n_is_tare=}")
        # print(f"{A[n] + B[n]=}, {n_is_sio=}")

        SIO[n] = max(n_is_sio, n_is_tare)

    # print(f"{TARE=}")
    # print(f"{SIO=}")
    if k == K:
        break
    else:
        # 繰り上げ
        TARE = SIO.copy()
        SIO = [0] * N


# print(f"{SIO=}")

print(SIO[-1])
0