| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1300289 | javahirbek | Knapsack (NOI18_knapsack) | Pypy 3 | 1061 ms | 51832 KiB |
import sys
input = sys.stdin.buffer.readline
S, N = map(int, input().split())
dp = [0] * (S+1)
for _ in range(N):
v, w, c = map(int, input().split())
if c * w >= S:
for j in range(w, S+1):
dp[j] = max(dp[j], dp[j-w] + v)
else:
for r in range(w):
q = []
for k in range((S-r)//w + 1):
idx = r + k*w
val = dp[idx] - k*v
while q and q[-1][1] <= val:
q.pop()
q.append((k, val))
while q and q[0][0] < k - c:
q.pop(0)
dp[idx] = max(dp[idx], q[0][1] + k*v)
print(dp[S])
컴파일 시 표준 출력 (stdout) 메시지
| # | 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... | ||||
