Submission #1111706

#TimeUsernameProblemLanguageResultExecution timeMemory
1111706slyceloteKnapsack (NOI18_knapsack)C++17
73 / 100
1078 ms1468 KiB
#include <iostream>
#include <vector>

using namespace std;

int main() {
    cin.tie(0); iostream::sync_with_stdio(false);
    int s, n; cin >> s >> n;
    vector<int> best(s+1);
    while (n--) {
        int v, w, k; cin >> v >> w >> k;
        k = min(k, s / w);
        while (k--) {
            for (int i = s-w; i >= 0; --i) {
                auto& r = best[i+w];
                r = max(r, best[i] + v);
            }
        }
    }
    cout << best[s] << endl;
}
#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...