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
const int mod = 1e9+7;
const int MAXN1 = 2e5 + 5;
const int MAXN2 = 1e6 + 5;
const int MAXN3 = 1e3 + 5;
void add_self(int &x, int y){
x = x+ y;
// return x;
}
int dp[2005], check[2005];
signed main () {
int s,n ;
cin >> s >> n;
dp[0] = 0;
for(int i = 0; i < n; i++){
int a,b,c;
cin >> a >> b >> c;
while(c--){
for(int j = 2000; j >= 0; j--){
if(j + b > 2000 )continue;
dp[j+b] = max(dp[j+b], dp[j] + a);
}
}
}
int ans = 0;
for(int i = 0; i <= s; i++){
// cout << dp[i] << "\n";
ans = max(ans, dp[i]);
}
cout <<ans;
}
# | 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... |