Help me in solving MOONSOON problem.one test case is failed

My issue

My code

#include <bits/stdc++.h>
using namespace std;

int main() {
	int t;
	cin>>t;
	while(t--)
	{
	    int n,m,k;
	    cin>>n>>m>>k;
	    int a[n],b[m];
	    for(int i=0;i<n;i++)
	    cin>>a[i];
	    for(int i=0;i<m;i++)
	    cin>>b[i];
	    sort(a,a+n);
	    sort(b,b+m);
	    long long int maxi=max(n,m),ans=0;
	    for(int i=0;i<maxi;i++)
	    {
	        if(i>=n || i>=m)
	        continue;
	        int temp1=b[m-i-1]*k;
	        ans=ans+min(temp1,a[n-i-1]);
	    }
	    cout<<ans<<endl;
	}
	return 0;
}

Problem Link: MOONSOON Problem - CodeChef

use long long temp1 and for array a and b.

Thank you for your valuable reply.Now it’s working

1 Like