Submission #975906

#TimeUsernameProblemLanguageResultExecution timeMemory
975906vjudge1Knapsack (NOI18_knapsack)C++17
17 / 100
1036 ms4568 KiB
#include <bits/stdc++.h> using namespace std; #define futaba ios_base::sync_with_stdio(false); cin.tie(NULL); #define rio return 0; #define ll long long // Fun things are fun. // ll dp[100005][2005], v[100005], k[100005]; int w[100005]; int main() { /* freopen(".txt", "r", stdin); freopen(".txt", "w", stdout); */ futaba int s, n; cin >> s >> n; for(int i = 1; i <= n; i++) cin >> v[i] >> w[i] >> k[i]; for(int i = 1; i <= n; i++) { for(int j = 0; j <= s; j++) { dp[i][j] = dp[i - 1][j]; for(int l = 0; l <= k[i]; l++) { if(j >= (w[i] * l)) dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - (w[i] * l)] + (l * v[i])); } } } cout << dp[n][s] << '\n'; rio }
#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...