Bingo! knapsack on the greatest capacity and done


#1

int Solution::solve(const vector &A, const vector &B, const vector &C) {

int capacity = *max_element(A.begin(),A.end());
vector<long > arr(capacity+1,INT_MAX);
arr[0] = 0 ;
    
for(int i = 0 ; i < B.size() ; i ++ )
    for(int j = B[i] ; j <= capacity ; j ++ )
        arr[j] = min(arr[j-B[i]]+C[i],arr[j]); 

for(auto cap : A) arr[0] += arr[cap];

return arr[0];
}