| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 876157 | CBG6682 | Knapsack (NOI18_knapsack) | C++14 | 1020 ms | 33588 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAXX = 1e5 + 5;
int s,n,dp[2001][MAXX];
struct Product{
int v,w,k;
};
Product product[MAXX];
bool cmp(Product a, Product b){
return a.w < b.w;
}
int main(){
cin >> s >> n;
for (int i = 0; i < n; i++) cin >> product[i].v >> product[i].w >> product[i].k;
sort(product,product + n,cmp);
for (int i = 1; i <= s; i++){
for (int j = 0; j < n; j++){
if (i >= product[j].w){
int num = 1;
while (num*product[j].w <= i && num <= product[j].k){
dp[i][j] = max(max(dp[i - num*product[j].w][j - 1] + product[j].v*num,dp[i][j]),max(dp[i - 1][j],dp[i][j - 1]));
num++;
}
}
}
}
cout << dp[s][n - 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... | ||||
