| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 870583 | mall0809 | Knapsack (NOI18_knapsack) | C++17 | 94 ms | 3864 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define C int(1e6+7)
#define M int(1e9+7)
#define el '\n'
#define all(a) a.begin(),a.end()
#define pb push_back
using namespace std;
typedef long long ll;
vector<array<int,2>> table[2002];
int dp[2002];
int main(){
//ios_base::sync_with_stdio(false);
//cin.tie(0);cout.tie(0);
//freopen("","r",stdin);
//freopen("","w",stdout);
int s,n;cin>>s>>n;
for(int i=1;i<=n;i++){
int v,w,k;cin>>v>>w>>k;
table[w].pb({v,k});
}
vector<int> val,w;
for(int i=1;i<=2000;i++){
sort(all(table[i]),greater<>());
int lim = s/i;
for(int j=0;j<table[i].size() && lim>0;j++){
for(int jj=1;jj<=table[i][j][1] && lim>0;jj++,lim--){
val.pb(table[i][j][0]);
w.pb(i);
}
}
}
for(int i=0;i<val.size();i++){
for(int j=s;j >= w[i];j--)dp[j] = max(dp[j],dp[j-w[i]] + val[i]);
}
cout<<dp[s];
}
컴파일 시 표준 에러 (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... | ||||
