Submission #1023803

#TimeUsernameProblemLanguageResultExecution timeMemory
1023803vjudge1Knapsack (NOI18_knapsack)C++17
0 / 100
6 ms456 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...