| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 877719 | Beerus13 | Knapsack (NOI18_knapsack) | C++14 | 1072 ms | 464 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
const int N = 1e5 + 5;
int n, S, val[N], w[N], sl[N];
int dp[2005];
int ans = 0;
int main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> S >> n;
for(int i = 1; i <= n; ++i) {
cin >> val[i] >> w[i] >> sl[i];
}
memset(dp, -0x3f, sizeof(dp));
dp[0] = 0;
for(int i = 1; i <= n; ++i) {
for(int j = sl[i]; j >= 1; --j) {
for(int k = S; k >= w[i]; --k) {
dp[k] = max(dp[k], dp[k - w[i]] + val[i]);
}
}
}
for(int i = 1; i <= S; ++i) ans = max(ans, dp[i]);
cout << ans;
return 0;
}| # | 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... | ||||
