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 <iostream>
using namespace std;
typedef long long ll;
const unsigned MAX = 100003, MAX_2 = 2003;
int s, n, v[MAX], w[MAX], k[MAX], sack[MAX_2];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> s >> n;
for (int i = 0; i < n; i++)
cin >> v[i] >> w[i] >> k[i];
for (int i = 0; i <= s; i++)
sack[i] = 0;
for (int i = 0; i < n; i++)
for (int j = s; j >= 0; j--)
for (int q = 1; q * w[i] <= j && q <= k[i]; q++)
sack[j] = max(sack[j], sack[j - q * w[i]] + q * v[i]);
cout << sack[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... |