結果
問題 |
No.2364 Knapsack Problem
|
ユーザー |
![]() |
提出日時 | 2025-03-04 03:49:20 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 831 bytes |
コンパイル時間 | 408 ms |
コンパイル使用メモリ | 82,060 KB |
実行使用メモリ | 76,400 KB |
最終ジャッジ日時 | 2025-03-04 03:49:31 |
合計ジャッジ時間 | 10,499 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 10 TLE * 2 -- * 8 |
ソースコード
from itertools import permutations 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())) D = list(map(int, input().split())) ans = 0 for perm1 in permutations(range(N)): for perm2 in permutations(range(M)): idx1 = 0 idx2 = 0 w = 0 v = 0 while idx1 < N: if w+A[perm1[idx1]] <= W: w += A[perm1[idx1]] v += B[perm1[idx1]] ans = max(ans, v) idx1 += 1 else: while idx2 < M and W < w+A[perm1[idx1]]: w -= C[perm2[idx2]] v -= D[perm2[idx2]] idx2 += 1 if W < w+A[perm1[idx1]] or w < 0: break print(ans)