結果

問題 No.2730 Two Types Luggage
ユーザー ああいい
提出日時 2024-05-23 19:37:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 699 ms / 2,000 ms
コード長 628 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 271,392 KB
最終ジャッジ日時 2024-12-20 19:03:26
合計ジャッジ時間 17,441 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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()))
S = [0] * N
A.sort(reverse = True)
S[0] = A[0]
for i in range(1,N):
    S[i] = A[i] + S[i-1]

l = [(0,0)]
for i in range(M):
    ll = []
    b = B[i]
    c = C[i]
    for w,cc in l:
        if w + b <= W:
            ll.append((w + b,cc + c))
    l += ll
ans = 0
for w,c in l:
    u = W - w
    tmp = c
    if 1 <= u <= N:
        tmp += S[u-1]
        #if tmp > ans:ans = tmp
    elif u == 0:
        pass
    else:
        tmp += S[-1]
    if tmp > ans:ans = tmp
print(ans)
        
    
0