The link to the problem is JOHNY.
The link to my code is CODE.
I’m getting WA for this. Before I got TLE because I sorted and got O(nlog n). But now it’s O(n).
I counted the number of elements lesser than a[k-1] and printed that number.
Can someone please help debug this?
An O(N \log N) solution is fine for this problem, so the fact that you got TLE must be due to some other reason.
Try moving the
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
to the first line in main
, rather that executing it for every testcase - doing that seems like a recipe for disaster
Edit:
From here:
2 Likes
Oh thank you. I used it in the wrong place . I’m getting a WA verdict though. How do I fix that?
Link to most recent solution?
1 Like
It got accepted after shifting the fast I/O. Thanks a lot for your help .
1 Like