public static long taumBday(int b, int w, int bc, int wc, int z) {
long rate=0;
if(bc==wc || (z>bc && z>wc)){
rate=(bc*b)+(wc*w);
}else if(bc>=(wc+z)){
rate=(wc*w)+(b*(wc+z));
}else if(wc>=(bc+z)){
rate=(bc*b)+(w*(bc+z));
}
return rate;
}
This is the logic which i created. It worked well for the initial test cases. but failed to produce correct answers for a lot of testcases.
can anyone help me find out where I have mistaken and what is the correct logic to solve this problem.
Thank you in advance.