Submission #1082797

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
10827972024-09-01 15:09:071tejasjainKnapsack (NOI18_knapsack)C++17
37 / 100
1054 ms604 KiB
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
//By Tejas India, https://www.linkedin.com/in/1tejasjain/
void call(){
int s, n; cin>>s>>n;
vector<int> maxValueByWeight(s+1, 0);
maxValueByWeight[0] = 0;
for(int item=1; item<=n; item++){
int value, weight, quantity; cin>>value>>weight>>quantity;
// cout<<"Item: "<<item<<endl;
for(int i=1; i<=quantity; i++)
for(int ks = s; ks>=0; ks--){
if(ks-weight>=0)
maxValueByWeight[ks] = max(maxValueByWeight[ks], maxValueByWeight[ks-weight]+value);
// cout<<ks<<": "<<maxValueByWeight[ks]<<" ";
}
// cout<<endl;
}
cout<<maxValueByWeight[s]<<endl;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t=1;
//cin>>t;
while(t--){
call();
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#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...