結果
問題 | No.2364 Knapsack Problem |
ユーザー | shogo314 |
提出日時 | 2023-06-30 21:34:14 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 856 bytes |
コンパイル時間 | 440 ms |
コンパイル使用メモリ | 87,132 KB |
実行使用メモリ | 81,340 KB |
最終ジャッジ日時 | 2023-09-21 15:23:55 |
合計ジャッジ時間 | 23,679 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 73 ms
75,744 KB |
testcase_01 | AC | 72 ms
71,408 KB |
testcase_02 | AC | 80 ms
75,832 KB |
testcase_03 | AC | 73 ms
71,364 KB |
testcase_04 | AC | 83 ms
76,084 KB |
testcase_05 | AC | 93 ms
76,128 KB |
testcase_06 | AC | 78 ms
76,064 KB |
testcase_07 | AC | 502 ms
77,320 KB |
testcase_08 | AC | 68 ms
71,480 KB |
testcase_09 | AC | 100 ms
76,744 KB |
testcase_10 | AC | 198 ms
77,328 KB |
testcase_11 | AC | 89 ms
76,832 KB |
testcase_12 | TLE | - |
testcase_13 | TLE | - |
testcase_14 | AC | 2,845 ms
77,416 KB |
testcase_15 | TLE | - |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
ソースコード
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 s in permutations(range(N)): for t in permutations(range(M)): i, j = 0, 0 w = 0 v = 0 # print(list(s), list(t)) while True: # print((w, v), (i, j)) if i < N and w+A[s[i]] <= W: w += A[s[i]] v += B[s[i]] ans = max(ans, v) i += 1 continue if j < M and w - C[t[j]] >= 0: w -= C[t[j]] v -= D[t[j]] ans = max(ans, v) j += 1 continue break # print((w, v), (i, j)) print(ans)