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