AFK - Editorial

Its giving correct answer. I think there is some issue with the large numbers because WA was there for subtask 2, subtask 1 was correct

Ok. Then what is your approach to deal with large no ??

My approach here - https://ideone.com/AGdtqY
Do look only when you tried all method yourshelf.

But only look it after looking above pseudo code and trying it yourshelf.
Most probably you will not need below code.

This was my hint of dealing +ve and -ve value separately.

Your AC (100 pts) edited soln https://www.codechef.com/viewsolution/18023970 here. :slight_smile: Happy coding.

P.S.
When I was giving test case where your code was giving correct answer. I was running your old code And it was giving incorrect ans. :slight_smile:
Specially Last two times and you found it to give correct answer.

Bonus karma’s for your effort. :slight_smile: Happy Coding :slight_smile:

#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t–){
long long a,b,c;
cin>>a>>b>>c;
long long d1=b-a;
// cout<<d1<<" “;
long long d2=c-b;
//cout<<d2<<” ";

        if((d2-d1)%2==0)
        cout<<(abs(d2-d1)/2)<<endl;
        else
            cout<<(abs(d2-d1)/2+1)<<endl;
    }
    return 0;
}

My solution : https://www.codechef.com/viewsolution/18007845.

After your hint, I also thought of something like that but was unable to come up with the condition (a+b<0) which actually made all that difference from WA to AC :slight_smile:
Thanks a lot @aryanc403 for working out with my code and finding the bug :slight_smile:

1 Like

Please check the number of test cases match the number of lines in the input. The number of lines after the first line does not match t.

Tests are valid T = 10000 and 1 + 10000 lines in both

I think it is not valid.
See this,
https://www.codechef.com/viewsolution/18045841

I changed the loop condition and it passed.

https://www.codechef.com/viewsolution/18045886

1.in has 10000 tests and 10001 lines, I don’t where is the problem. Let me check