| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1304104 | Zone_zonee | Knapsack (NOI18_knapsack) | C++20 | 2 ms | 580 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5+10, S = 2e4+10;
ll dp[S];
pair<int, int> a[N*32];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int s, n;
cin >> s >> n;
int sz = 0;
for(int i = 1; i <= n; ++i){
int v, w;
ll k;
cin >> v >> w >> k;
for(int j = 0; k > 0; ++j){
a[sz++] = {w*min(k, 1LL<<j), v*min(k, 1LL<<j)};
k -= min(k, 1LL<<j);
}
}
for(int j = 0; j < sz; ++j){
auto [w, v] = a[j];
for(int i = s; i >= w; --i){
dp[i] = max(dp[i], dp[i-w] + v);
}
}
cout << dp[s] << '\n';
}| # | 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... | ||||
