結果
問題 |
No.2730 Two Types Luggage
|
ユーザー |
👑 |
提出日時 | 2024-04-19 21:42:34 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,133 ms / 2,000 ms |
コード長 | 597 bytes |
コンパイル時間 | 297 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 268,728 KB |
最終ジャッジ日時 | 2024-10-11 14:32:38 |
合計ジャッジ時間 | 18,718 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
from itertools import combinations, accumulate N, M, W = map(int, input().split()) A = sorted(map(int, input().split()), reverse=True) B = list(map(int, input().split())) C = list(map(int, input().split())) acc_A = [0] + list(accumulate(A)) ans = acc_A[min(W, N)] for i in range(1, M+1): for comb in combinations(zip(B, C), r=i): sum_weight = sum([b for b, _ in comb]) sum_value = sum([c for _, c in comb]) if sum_weight > W: continue value = sum_value + acc_A[min(W - sum_weight, N)] ans = max(ans, value) print(ans)