Hello Codeforces!
I submitted my solution for 2275D - Precision Alignment , but I'm getting WA 2 I have spent a while trying to find where my logic fails or what edge case breaks my binary search check function, but I haven't been able to spot the bug yet.
My Approach: Binary Search on Answer: I am binary searching for the answer mid in the range [-3e18, 3e18] using __int128 arithmetic to prevent overflow.
Check Function (check(mid)): For each element/triplet $$$A[i] = (a, b, c)$$$, I evaluate if we can meet or adjust the condition using available operations $$$k$$$: Compute signs of differences: $$$a - b$$$, $$$a - c$$$, and $$$b - c$$$.If $$$a = b = c$$$, I immediately return false. If the signs indicate a non-increasing state ($$$\le 0$$$) , I calculate the minimum operations needed (sm1) by adjusting values (using delta logic with abs) and adding the remaining needed magnitude to reach mid Accumulate total operations into op and ensure op <= k.
My Submission : 393623669








im unable to open ur submission can you send ur code to me somehow maybe write it in reply or write it in ideone and send me the link
tho this code gave some compilation errors which I needed to fix for some reason but yeah I found this case:
my code gives 26 for this while yours gave 27
here is a possible explanation:
look at this block of code
In your sgn1 == -1 block, you update c -= idk and then immediately recalculate abs128(b — c) inside the min(...) function. Because c is now exactly b — 1, that absolute difference always = 1, which I have a suspicion that this isnt true lol
The Fix: Use your pre-calculated idk inside the min() call instead of re-evaluating the modified variables, exactly like you did for el1 below.
the fix mentioned above did give me an ac here is the corrected sgn == -1 if you need it:
Oh got it my bad.
yes but next time let us spy on your code if you want us to fix it. Lemme see ur submissions
// WHY DO YOU KEEP SPYING ON MY CODE GO SOLVE A PROBLEM -_-Permission granted for you :)
I want permission too
for hacking my code next time? -_-
yes :)
nah :)