이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
max_capacity, items_cnt = map(int, input().split())
prev_state = [0] * (max_capacity + 1)
for item_i in range(items_cnt):
value, weight, quantity = map(int, input().split())
new_state = prev_state.copy()
for cur_capacity in range(max_capacity + 1):
if cur_capacity > 0:
new_state[cur_capacity] = max(new_state[cur_capacity], new_state[cur_capacity - 1])
for cur_quantity in range(1, quantity + 1):
if cur_quantity * weight > cur_capacity:
break
new_state[cur_capacity] = max(new_state[cur_capacity], prev_state[cur_capacity - cur_quantity * weight] + cur_quantity * value)
prev_state = new_state
print(prev_state[-1])
# | 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... |