| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 555607 | DeMen100ns | Knapsack (NOI18_knapsack) | C++17 | 129 ms | 5772 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
Author : DeMen100ns (a.k.a Vo Khac Trieu)
School : VNU-HCM High school for the Gifted
fuck you adhoc
*/
#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5;
const long long INF = 1e18 + 7;
const int MAXA = 1e9;
const int B = sqrt(N) + 5;
vector <int> obj[N];
int dp[N];
void solve()
{
int s, n;
cin >> s >> n;
for(int i = 1; i <= n; ++i){
int v, w, k;
cin >> v >> w >> k;
k = min(k, s / w);
int tmp = 1;
while (k){
int V = v * tmp, W = w * tmp;
obj[W].push_back(V);
k -= tmp;
tmp = min(tmp * 2, k);
}
}
int ma = 0;
for(int i = 1; i <= s; ++i){
sort(obj[i].begin(), obj[i].end(), greater<int>());
while (obj[i].size() > s / i){
obj[i].pop_back();
}
for(int v : obj[i]){
for(int w = s; w >= i; --w){
dp[w] = max(dp[w], dp[w - i] + v);
ma = max(ma, dp[w]);
}
}
}
cout << ma;
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// freopen("codeforces.inp","r",stdin);
// freopen("codeforces.out","w",stdout);
int t = 1; // cin >> t;
while (t--)
{
solve();
}
}컴파일 시 표준 에러 (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... | ||||
