# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
684864 | Farhan_HY | Knapsack (NOI18_knapsack) | C++14 | 1047 ms | 68428 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>
#define int long long
#define F first
#define S second
#define T int t; cin >> t; while(t--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 2005;
const int M = 1e3 + 3;
const int mod = 1e9 + 7;
int n, s, dp[N][N];
vector<pair<int, int>> vec[N];
vector<int> weights[N];
int Rec(int i, int j) {
if (i > s) return 0;
int &ret = dp[i][j];
if (ret != -1) return ret;
ret = Rec(i + 1, j);
int value = 0;
for(int k = 0; k < weights[i].size(); k++) {
value += weights[i][k];
if (j + (k + 1) * i <= s)
ret = max(ret, Rec(i + 1, j + (k + 1) * i) + value);
}
return ret;
}
main() {
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... |