結果

問題 No.2364 Knapsack Problem
ユーザー ニックネームニックネーム
提出日時 2023-06-30 21:51:50
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 555 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 77,460 KB
最終ジャッジ日時 2023-09-21 15:47:43
合計ジャッジ時間 6,833 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
75,712 KB
testcase_01 AC 68 ms
71,324 KB
testcase_02 AC 75 ms
75,660 KB
testcase_03 AC 69 ms
71,344 KB
testcase_04 AC 80 ms
76,332 KB
testcase_05 AC 89 ms
76,048 KB
testcase_06 AC 80 ms
76,160 KB
testcase_07 AC 517 ms
77,040 KB
testcase_08 AC 71 ms
71,192 KB
testcase_09 AC 105 ms
76,840 KB
testcase_10 AC 206 ms
77,268 KB
testcase_11 AC 91 ms
76,660 KB
testcase_12 TLE -
testcase_13 TLE -
testcase_14 AC 2,833 ms
77,096 KB
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import permutations
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
d = list(map(int,input().split()))
ans = 0
for px in permutations(range(n)):
    for py in permutations(range(m)):
        i = j = w = v = 0
        while i<n or j<m:
            if i<n and w+a[px[i]]<=k: w += a[px[i]]; v += b[px[i]]; i += 1
            elif j<m and 0<=w-c[py[j]]: w -= c[py[j]]; v -= d[py[j]]; j += 1
            else: break
            ans = max(ans,v)
print(ans)
0