@samtoosoon Find the longest non-decreasing suffix (fix). Keep a running non-decreasing prefix (running). For each running, if last(running) ≤ first(fix), removal = fixStart−runningEnd−1. While fix < running, move fix ahead. Take min removal. Edge cases: remove full prefix/suffix.
Else all paths are monotone. Split in Si<Ti and Si>Ti, their intervals don’t overlap. Right-goers safe in descending Si since each departs before blocking anyone behind. Left-goers safe in ascending Si since each clears before the next arrives. Combine both gives no fight order.
Idea:
Key: Sort by starts. If targets not sorted too, then ∃i<j with Si<Sj but Ti>Tj. In that case whichever moves first, the other’s target lies inside its path. This forces a collision, so no permutation exists and the answer is No.
E. Min-Max Deque (Greedy)
Only border values of B matter.
Once an element leaves border, never comes back.
At step i, Ai must be border.
So:
Alice replaces min(x,y) with Ai (keeps both large).
Bob replaces max(x,y) with Ai (pushes small).
Finally ends = (An, x). Ans = min(An, x).
Binary Search on answer :
If Alice can secure value x, then she can also secure any ≤ x.
If she fails at x, she fails at all > x.
Since monotonic so, binary search the largest feasible x.
That’s exactly f(A), Alice’s guaranteed final score.
A: If X == 4 then H else 24 * (X − 4) + H
B: If (50 - X) lies in [2Y, 2Y+10] then Yes else No
C: Brute over small N and try all (2i + 3j = N), take min cost.
D: If (A[i] > A[i + 1]) then [i, i+1] works else -1
E: Minimax Binary search + greedy if Alice can force score ≥ x
50K Followers 9K Followingchilling | ex swe intern @cisco / ex research @ai4bharat
https://t.co/UfNnMe4nMe (4.5k users) | https://t.co/483196ilYx (7k users)
2K Followers 7K FollowingFull Stack Developer | AI Builder
Building web apps, AI automations & software solutions
Sharing my journey with LLMs, RAG & AI Agents
Open to opportunities
35K Followers 1K Following24 • backend dev • building @devlogz • ex @Flipkart • building things that just work • learning systems & low level stuff • love video games & pixel art
4K Followers 1K Followingi turn ZK & cryptography research into things you can actually understand | intern @nethermind | prev intern @OpenZeppelin | @torbitxyz