# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1023724 | vjudge1 | Knapsack (NOI18_knapsack) | C++17 | 1016 ms | 49808 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;
#define int long long
#define pb push_back
#define ff first
#define ss second
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
const int inf = 1e9;
signed main() {
int n, s;
cin >> s >> n;
vector<int> v, w;
for (int i = 0; i < n; i++) {
int a, b, c;
cin >> a >> b >> c;
for (int j = 1; j <= c; j++) {
v.pb(a);
w.pb(b);
}
}
vector<int> dp(s + 1, 0);
for (int i = 0; i < v.size(); i++) {
for (int j = s; j >= w[i]; j--) {
dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
}
}
cout << dp[s];
}
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... |