Submission #680377

#TimeUsernameProblemLanguageResultExecution timeMemory
680377sz1218Knapsack (NOI18_knapsack)C++14
12 / 100
1 ms304 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef vector<int> vi; const int NN = 1e6+3; int n, S, used[2003]; ll dp[2003]; int main() { //setIO(""); cin >> S >> n; int V, W, K; for(int i=0;i<n;i++){ cin >> V >> W >> K; memset(used, 0, sizeof(used)); for(int i=1;i<=S;i++){ if(i-W >= 0 && dp[i-W] + V > dp[i] && used[i-W] <= K-1){ used[i] = used[i-W] + 1; dp[i] = dp[i-W] + V; } } } ll ans = 0; for(int i=0;i<=S;i++){ans = max(ans, dp[i]);} cout << ans << endl; return 0; }
#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...