Actually i just saw i referred to it by offline solution only. Didn’t realize this until i posted the editorial, that i have not named the offline solution.
No, Test cases cannot be shared, as per codechef rules. You can see detailed discussion or put forward your views if you wish to, at link below.
I submitted your code in practice, and it got AC. This is a known problem.
Your solution tries to iterate over range of size up to 1e9, which cannot be completed in one second. Assume 1e7 iteration can be done in one second.
For a binary search solution, you may refer any solution in practice using binary search. I found this solution, doing binary search using lower_bound function.
Offline mode means we read all queries first, answering them in some specific order and printing answers according to their order in input.
So why my solution got WA for rest of 70 points during the contest.
You’re passing on the vector in
int binarysearch(vector<pair<ll,ll> > v1,ll l,ll r,ll key) by value, so you copy a vector of pairs for every single call to binary search. Make that a reference
int binarysearch(vector<pair<ll,ll> > &v1,ll l,ll r,ll key) and you should get decent running times.
You’re passing the vector by value in your binary search. That by itself is O(n). Pass it by reference.
Can anyone help me with the code , it is giving runtime
Could anyone please check my code why is it not working ? i am getting runtime error.