| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1332795 | yumemystery | Knapsack (NOI18_knapsack) | C++20 | 1095 ms | 436 KiB |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int W,n;
cin >> W >> n;
vector<ll>dp(W+1,0);
for (int i=0; i<n; i++) {
ll v,w,k;
cin >> v >> w >> k;
int c = 1;
while (k >= c) {
for (int j = W; j>=c*w; j--) dp[j] = max(dp[j],dp[j-c*w]+c*v);
k-=c;
c <<= 1;
}
if (k) for (int j = W; j>=k*w; j--) dp[j] = max(dp[j],dp[j-k*w]+k*v);
}
cout << dp[W];
}| # | 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... | ||||
