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>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("Ofast")
#define pii pair <int, int>
#define pb push_back
#define pp pop_back
#define int int64_t
#define sc second
#define fr first
using namespace std;
signed main() {
ios::sync_with_stdio(0);
cout.tie(0);
cin.tie(0);
double n, s, i, j, mx=0, a, b, c;
cin >> n >> s;
vector <double> dp(n+1);
for (i=1; i<=s; i++) {
cin >> a >> b >> c;
c=min(n, ceil(c/b));
// cout << c << '\n';
while (c--) {
for (j=n; j>=0; j--) {
if (j==0 && b<=n) dp[b]=max(dp[b], a);
if (dp[j]>0 && j+b<=n) dp[j+b]=max(dp[j+b], dp[j]+a);
}
}
}
for (i=0; i<=n; i++) {
// cout << dp[i] << ' ';
mx=max(dp[i], mx);
}
cout << mx;
}
# | 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... |