# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
896684 | blackslex | Knapsack (NOI18_knapsack) | C++17 | 1056 ms | 440 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int M = 2005;
ll n, m, dp[M];
int main() {
scanf("%lld %lld", &m, &n);
vector<ll> w(n), v(n), k(n);
for (int i = 0; i < n; i++) scanf("%lld %lld %lld", &v[i], &w[i], &k[i]);
for (int i = 0; i < n; i++) while (k[i]--) for (int j = m; j >= 0; j--) if (j - w[i] >= 0) dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
printf("%lld", dp[m]);
}
Compilation message (stderr)
# | 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... |