| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1266322 | nathlol2 | Knapsack (NOI18_knapsack) | C++20 | 0 ms | 324 KiB |
#include <bits/stdc++.h>
using namespace std;
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int s, n;
cin >> s >> n;
vector<int> a, b;
for(int i = 0;i<n;i++){
int p, w, m;
cin >> p >> w >> m;
for(int j = 1;j<=m;j++){
if(w * j > s){
break;
}
a.push_back(p * j);
b.push_back(w * j);
}
}
int sz = a.size();
vector<int> dp(s + 1), prev(s + 1);
for(int i = 0;i<sz;i++){
for(int j = s;j>=b[i];j--){
dp[j] = max(dp[j], prev[j - b[i]] + a[i]);
}
swap(dp, prev);
}
cout << prev[s] << '\n';
}| # | 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... | ||||
