| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1359227 | atif2077 | Knapsack (NOI18_knapsack) | C++20 | 678 ms | 452 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
signed main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
ll S, N;
cin >> S >> N;
vector<ll> dp(S + 1, 0);
for (ll i = 0; i < N; i++)
{
ll V, W, K;
cin >> V >> W >> K;
ll cnt = 1;
while (K > 0)
{
ll take = min(cnt, K);
ll weight = W * take;
ll value = V * take;
for (ll s = S; s >= weight; s--)
{
dp[s] = max(dp[s], dp[s - weight] + value);
}
K -= take;
cnt <<= 1;
}
}
cout << dp[S];
return 0;
}| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
