I'm failing 2nd testcase in Subtask-2 and 4th testcase in Subtask-3. Any idea where I've failed to consider a scenario ?

sum = 0;for(int i=0;i<n;i++){/* If A can handle more orders and he gets more tip on order i*//* Or B reached his/her max, and remaining must be taken by A*/if((x && a[i] >= b[i]) || !y){sum += a[i];if(x>0) x--;}else if (y || !x){sum += b[i];if(y>0) y--;}}

Read more… (21 words)