using namespace std;
if(a>b && (a-b)>dif)
As mentioned by @vijju123, you would need to calculate the cumulative lead after each round and then check for the diff. Currently, with
b-a>dif, you are checking for lead in each round.
Try accumulating a’s and b’s individually, say in ‘x’ and ‘y’, and then check for difference of x and y instead of directly checking for the difference of ‘a’ and ‘b’.
Cumulative lead, not lead per round.
Thankyou, I’d missed the “cumulative” in there. Thanks a lot.