結果

問題 No.2730 Two Types Luggage
ユーザー june19312
提出日時 2024-04-19 23:31:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,515 ms / 2,000 ms
コード長 737 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 82,020 KB
実行使用メモリ 269,604 KB
最終ジャッジ日時 2024-10-11 18:12:55
合計ジャッジ時間 20,721 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

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

A.sort()
A.reverse()
rui = []
for i,v in enumerate(A):
    if i == 0:
        rui.append(v)
    else:
        rui.append(rui[-1]+v)

rui = [0] + rui

all = 2**M
alllen = (all-1).bit_length()
ans = 0

for i in range(all):
    nex = bin(i)[2:].zfill(alllen)
    tmpvalue = 0
    tmpomosa = 0
    for ii,vv in enumerate(nex):
        if vv == "1":
            tmpvalue += C[ii]
            tmpomosa += B[ii]
    if tmpomosa > W:
        continue
    nokori = W-tmpomosa
    if nokori >= N:
        tmpvalue += rui[-1]
    else:
        tmpvalue += rui[nokori]
    ans = max(ans,tmpvalue)
print(ans)


0