結果
| 問題 |
No.2364 Knapsack Problem
|
| コンテスト | |
| ユーザー |
ニックネーム
|
| 提出日時 | 2023-06-30 21:51:50 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 555 bytes |
| コンパイル時間 | 135 ms |
| コンパイル使用メモリ | 81,776 KB |
| 実行使用メモリ | 83,304 KB |
| 最終ジャッジ日時 | 2024-07-07 09:33:09 |
| 合計ジャッジ時間 | 29,308 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 14 TLE * 5 -- * 1 |
ソースコード
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)
ニックネーム