제출 #1134767

#제출 시각아이디문제언어결과실행 시간메모리
1134767nikolashamiKnapsack (NOI18_knapsack)C++20
73 / 100
1096 ms1352 KiB
#include<bits/stdc++.h> using namespace std; int a[(int)1e5][3],f[2001]; int main(){ int m,n; cin>>m>>n; for(int i=0;i<n;++i){ cin>>a[i][1]>>a[i][0]>>a[i][2]; a[i][2]=min(a[i][2],m); } for(int i=0,j;i<n;++i){ j=1; while(a[i][2]){ int s=min(a[i][2],j); a[i][2]-=s; for(int k=m;k>=a[i][0]*s;--k) f[k]=max(f[k],f[k-a[i][0]*s]+a[i][1]*s); j*=2; } } cout<<*max_element(f,f+m+1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...