| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1319375 | ledinhmanh0401 | Knapsack (NOI18_knapsack) | C++20 | 1089 ms | 444 KiB |
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define endl '\n'
using namespace std;
const ll MOD = 1e9+7;
void setup(){
if(fopen("input.INP", "r")){
freopen("input.INP", "r", stdin);
freopen("output.OUT", "w", stdout);
}
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
int main(){
setup();
int s,n;
cin>>s>>n;
vector<ll> dp(s+1,0);
for(int i=1;i<=n;i++){
ll v,w,k;
cin>>v>>w>>k;
k=min(k,(ll)s/w);
for(ll t=1;k>0;t*=2){
ll take=min(t,k);
ll wt=take*w;
ll val=take*v;
for(int j=s;j>=wt;j--)
dp[j]=max(dp[j],dp[j-wt]+val);
k-=take;
}
}
cout<<*max_element(dp.begin(),dp.end());
return 0;
}
컴파일 시 표준 에러 (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... | ||||
