| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 954977 | vis786 | Knapsack (NOI18_knapsack) | Cpython 3 | 1086 ms | 24212 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
S,N = map(int,input().split())
V,W,K = [],[],[]
for n in range(N):
Vi,Wi,Ki = map(int,input().split())
V.append(Vi)
W.append(Wi)
K.append(Ki)
mem = {}
def maxValue(weight,i):
if (weight,i) in mem:
return mem[(weight,i)]
if i == N:
return 0
m = 0
count = K[i]
new_weight = weight
new_i = i+1
while count >= 0 and new_weight <= S:
m = max(m,maxValue(new_weight,new_i)+(K[i]-count)*V[i])
count -= 1
new_weight += W[i]
mem[(weight,i)] = m
return mem[(weight,i)]
print(maxValue(0,0))| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
