結果
問題 | No.2730 Two Types Luggage |
ユーザー |
![]() |
提出日時 | 2024-06-13 05:06:48 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 936 ms / 2,000 ms |
コード長 | 784 bytes |
コンパイル時間 | 348 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 266,144 KB |
最終ジャッジ日時 | 2024-06-13 05:07:11 |
合計ジャッジ時間 | 21,450 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
import itertools# M<=20よりMについて全探索N, M, W = map(int, input().split())A = sorted(list(map(int, input().split())))[::-1]As = list(itertools.accumulate(A))B = list(map(int, input().split()))C = list(map(int, input().split()))cnt = []for i in range(2**M):ws = 0ps = 0flag = Truefor j in range(M):if ((i >> j) & 1):ws += B[j]ps += C[j]if ws > W:flag = Falsebreakif flag:if ws == W:cnt.append(ps)else:remaining_weight = W - wsif remaining_weight - 1 < len(A):cnt.append(ps + As[remaining_weight - 1])else:cnt.append(ps + As[-1])print(max(cnt))"🐬"