| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1321943 | jim_x | Knapsack (NOI18_knapsack) | C++17 | 1092 ms | 424 KiB |
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <numeric>
#include <queue>
#include <stack>
#include <iomanip>
using namespace std;
void baseIO(string s = ""){
ios_base::sync_with_stdio(0);
cin.tie(0);
if (s.size()){
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
}
int main() {
baseIO();
int s, n;
cin >> s >> n;
int dp[s + 1]{};
for (int i = 0; i < n; i++){
int a, b, c;
cin >> a >> b >> c;
c = min(c, s / b);
while (c--){
for (int pos = s - b; pos >= 0; pos--){
dp[pos + b] = max(dp[pos + b], dp[pos] + a);
}
}
}
cout << *max_element(dp, dp + s + 1);
return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
