Test cases not run

maintained a min heap of costs

@dakshi
No. It can be solved with an even greedier approach. Think about it.

here is my code
#include
#include<bits/stdc++.h>
using namespace std;
int main() {
int t;
cin>>t;
while(t–)
{
int n;
cin>>n;
int cost[n];
for(int i=0;i<n;i++)
cin>>cost[i];
int l[n];
for(int i=0;i<n;i++)
cin>>l[i];
int c=0;
int cap=0;
int ans=INT_MAX;
for(int i=0;i<n;i++)
{
if(ans>cost[i])
ans=cost[i];
c=c+(l[i]*ans);
}
cout<<c<<endl;
}
return 0;

}

@dakshi
Use long long int instead of int and try it out.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.