| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1364710 | hexopia | Knapsack (NOI18_knapsack) | C++20 | 0 ms | 344 KiB |
#include <bits/stdc++.h>
using namespace std;
int dp[2005];
int32_t main() {
ios_base::sync_with_stdio(0),cin.tie(0);
int s,n;cin>>s>>n;
for(int i = 0 ; i<=s ; ++i) dp[i] = -1e9;
dp[0] = 0;
for(int i = 0 ; i<n ; ++i) {
int v,w,k;cin>>v>>w>>k;
for(int j = 1; k ; j<<=1) {
int num = min(j,k);
k-=num;
for(int l = s ; l>=w*num; --l) {
if(dp[l-w*num] != -1e9) dp[l] = max(dp[l],dp[l-w*num]+v*num);
}
}
}
int ans = 0;
for(int i = 0 ; i<=s ; ++i) ans = max(ans,dp[i]);
cout << ans;
}| # | 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... | ||||
