Please help.
sample input is giving correct output but test cases are not passing.
link of the question- https://hack.codingblocks.com/contests/c/452/104
link of the code- https://ide.codingblocks.com/#/s/16943
Please help.
sample input is giving correct output but test cases are not passing.
link of the question- https://hack.codingblocks.com/contests/c/452/104
link of the code- https://ide.codingblocks.com/#/s/16943
Hy Kanupriya
Your code was 99.9% correct the only issue was you were not updating the values of variables to zero for new fresh test case. Here is the updated code
#include<iostream>
using namespace std;
int main()
{
int c1,c2,c3,c4,n,m,i,A=0,B=0,A1=0,B1=0,res=0;
int t;
cin>>t;
while (t--)
{
cin>>c1>>c2>>c3>>c4;
cin>>n>>m;
//Updated code area start
A=0,B=0,A1=0,B1=0,res=0;
//Updated code area end
int *r = new int [n];
int *cab = new int [m];
for(i=0;i<n;i++)
{
cin>> r[i];
}
for(i=0;i<m;i++)
{
cin>> cab[i];
} // got all the inputs
for(i=0;i<n; i++)
{
A+= min(c1*r[i], c2);
A1 = min(A,c3);
}
for(i=0; i<m ; i++)
{
B += min(c1*cab[i], c2);
B1 = min(B,c3);
}
res = min(c4,A1+B1);
cout << res<<endl;
}
return 0;
}
thank you so much sanket