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>
#include <vector>
#define ll long long
#define ull unsigned long long
#define pii std::pair<int, int>
#define IO (std::string) ""
std::ifstream fin(IO + ".in");
std::ofstream fout(IO + ".out");
#define NMAX 100'007
#define SMAX 2007
int n, s;
int v[NMAX], w[NMAX], k[NMAX];
std::vector<int> dp;
void citire() {
std::cin >> s >> n;
for (int i = 1; i <= n; i++)
std::cin >> v[i] >> w[i] >> k[i];
dp.resize(s + 1);
}
int main() {
citire();
for (int i = 1; i <= n; i++) {
for (int j = s; j >= 0; j--) {
for (int x = 0; j - w[i] * x >= 0 && x <= k[i]; x++) {
dp[j] = std::max(dp[j], dp[j - x * w[i]] + x * v[i]);
}
}
}
std::cout << dp[s];
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... |