結果

問題 No.2852 Yakitori Optimization Problem
ユーザー Yuyo1984Yuyo1984
提出日時 2024-08-25 15:14:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 824 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 105,116 KB
最終ジャッジ日時 2024-08-25 15:14:48
合計ジャッジ時間 22,731 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

n, k = map(int, input().split())
A = [*map(int, input().split())]
B = [*map(int, input().split())]
C = [*map(int, input().split())]

D = list()
idx_d = 0
for a, b in zip(A, B):
    D.append((a + b, 0, idx_d))
    idx_d += 1

idx_e = 0
E = list()
for a, c in zip(A, C):
    E.append((a + c, 1, idx_e))
    idx_e += 1

F = D + E
used = set()

ans = 0
F.sort(reverse=True)

made_salt = 0
made_sauce = 0
for i in range(len(F)):
    if F[i][2] not in used:
        if F[i][1] == 0:
            if made_salt < k:
                ans += F[i][0]
                made_salt += 1
                used.add(F[i][2])
        elif F[i][1] == 1:
            if made_sauce < n - k:
                ans += F[i][0]
                used.add(F[i][2])
                made_sauce += 1
    if made_salt + made_sauce == n:
        break

print(ans)
0