Submission #1312647

#TimeUsernameProblemLanguageResultExecution timeMemory
1312647melissakKnapsack (NOI18_knapsack)C++20
37 / 100
1095 ms332 KiB
#include <iostream> #include <string> #include <vector> #include <cmath> #include <unordered_set> #include <unordered_map> #include <set> #include <algorithm> #include <cctype> #include <limits> #include <iomanip> #include <stack> #include <numeric> #include <map> #include <queue> #include <cfloat> #include <climits> using namespace std; using ll = long long; const ll MOD = 1e9 + 7; const ll MAX_SAFE_LL = 1e18; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int s, n; cin >> s >> n; vector<ll> dp(s + 1); for(int i = 0; i < n; ++i) { int v, w, c; cin >> v >> w >> c; for(int j = 0; j < c; ++j) { for(int k = s; k >= w; --k) { dp[k] = max(dp[k], dp[k - w] + v); } } } cout << dp[s] << '\n'; 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...