# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
770788 | vgoofficial | Knapsack (NOI18_knapsack) | C++14 | 58 ms | 35028 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int s,n;
cin >> s >> n;
vector<vector<pair<int, int>>> items(s+1);
for(int i = 0; i < n; i++) {
int value, weight, number;
cin >> value >> weight >> number;
items[weight].push_back(make_pair(value, number));
}
for(int i = 1; i <= s; i++) {
sort(begin(items[i]), end(items[i]), [](const pair<int, int> a, const pair<int, int> b) -> bool{
return a.first>b.first;
});
}
ll arr[s+1][s+1];
//arr[a][b]=x: first a weights, b total weight, x max value
for(int i = 0; i <= s; i ++) {
for(int j = 0; j <= s; j++) {
arr[i][j]=0;
}
}
for(int i = 1; i <= s; i++) {
for(int j = 0; j <= s; j++) {
arr[i][j]=max(arr[i-1][j], arr[i][j]);
컴파일 시 표준 에러 (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... |