This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/****ThanhCodeDao*****/
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef long long ll;
const ll maxN = 100005, modd = 1e9+7;
ll f[2005], w[maxN], v[maxN], k[maxN];
ll n,s;
void solve() {
//freopen("inp.txt","r",stdin);
//freopen("out.txt","w",stdout);
cin >> s >> n;
for(ll i = 1;i<=n;i++){
cin >> v[i] >> w[i] >> k[i];
}
for(ll i = 1;i<=n;i++){
for(ll j = s;j>=w[i];j--){
for(ll t = 1;t<=k[i];t++){
ll sl = t, add = sl * v[i], cost = sl * w[i];
if(cost > j) break;
f[j] = max(f[j],f[j-cost] + add);
}
}
}
cout << f[s];
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
solve();
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... |