# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
719610 | JANCARAPAN | Knapsack (NOI18_knapsack) | C++17 | 2 ms | 340 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 ll long long
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define sz(a) (long long) a.size()
#define endl '\n'
#define dbg(a) cerr << #a << " = " << a << endl;
#define print(a) for (auto x : a) cerr << x << " "; cerr << endl;
const long long INF = 1e18, MOD = 1e9 + 7;
void solve(){
int s, n;
cin >> s >> n;
vector<int> v(n), w(n), k(n);
for (int i = 0; i < n; i++) {
cin >> v[i] >> w[i] >> k[i];
}
vector<ll> dp(s + 1);
for (int i = 0; i < n; i++) {
vector<ll> already(s + 1), ndp(s + 1);
for (int j = 0; j <= s; j++) {
ndp[j] = dp[j];
if (j < w[i]) continue;
if (dp[j - w[i]] + v[i] > dp[j]) {
# | 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... |