# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
523916 | _karan_gandhi | Knapsack (NOI18_knapsack) | C++17 | 1088 ms | 2636 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 ll long long
#define all(v) v.begin(), v.end()
#define endl '\n'
#define pl(var) " [" << #var << ": " << (var) << "] "
#define value 0
#define weight 1
#define number 2
ll int mod = 1e9 + 7;
void solve() {
ll int s, n; cin >> s >> n;
vector<array<ll int, 3>> arr(n);
for (int i = 0; i < n; i++) {
cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
}
vector<ll int> dp(s + 1, 0);
for (int i = 0; i < n; i++) {
for (int j = s; j >= 1; j--) {
ll int cur = 1;
while ((j - (arr[i][weight] * cur)) >= 0 && cur <= arr[i][number]) {
dp[j] = max(dp[j], dp[j - arr[i][weight] * cur] + arr[i][value] * cur);
cur++;
}
# | 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... |