| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1124789 | dwuy | Knapsack (NOI18_knapsack) | C++17 | 1095 ms | 2628 KiB |
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MX = 100005;
int S, n;
int v[MX], w[MX], k[MX];
int f[2005];
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> S >> n;
for(int i=1; i<=n; i++) cin >> v[i] >> w[i] >> k[i];
for(int i=1; i<=n; i++){
k[i] = min(k[i], S/w[i]);
for(int t=1; k[i]>0; t=min(k[i], t<<1)){
int val = v[i]*t;
int wei = w[i]*t;
for(int j=S; j>=wei; j--){
f[j] = max(f[j], f[j-wei] + val);
}
k[i] -= t;
}
}
cout << *max_element(f + 0, f + S + 1);
return 0;
}| # | 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... | ||||
