Submission #889942

#TimeUsernameProblemLanguageResultExecution timeMemory
889942math_piKnapsack (NOI18_knapsack)C++14
17 / 100
1 ms604 KiB
#include<bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int dp[3<<17]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int s, n; cin >> s >> n; vector<int> v(n), w(n), q(n); for(int i=0; i<n; i++) { cin >> v[i] >> w[i] >> q[i]; } for(int j=0; j<n; j++) { for(int i=s; i>=1; i--) { if(i >= w[j]) dp[i] = max(dp[i], dp[i-w[j]] + v[j]); } } cout << dp[s] << '\n'; }
#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...