| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1355377 | li1005345206 | Knapsack (NOI18_knapsack) | Pypy 3 | 1101 ms | 198888 KiB |
import os
import sys
input=lambda:sys.stdin.readline().strip()
minput=lambda:map(int,input().split())
S,N=minput()
kvw=[minput() for i in range(N)]
dp = [[0] * (S + 1) for _ in range(2)]
ind = 0
while kvw:
V,W,K=kvw.pop()
base = 1
if K > 2047:
K = 2047
while K > 0:
if K >= base:
K -= base
else:
base = K
K = 0
v = V * base
w = W * base
prev = ind & 1
ind = (ind + 1) & 1
for j in range(S + 1):
dp[ind][j] = dp[prev][j]
if j >= w:
dp[ind][j] = max(dp[ind][j], dp[prev][j - w] + v)
base <<= 1
print(max(map(max, dp)))
Compilation message (stdout)
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
