Scan From Both Ends: How One Line Took My Divide and Conquer From TLE to AC

My solution to Vlad, Misha and Two Arrays was correct and still got TLE on test 14. The fix was to check the split candidates in the order l, r, l+1, r-1, … instead of left to right. Here is why that one change turns O(n²) into O(n log n).

September 26, 2026 · 8 min · Priyanshu Debnath

Why My PBDS ordered_multiset Solution TLE'd (and the Fenwick Fix)

My approach to Zhily and Barknights was correct from the start, but the PBDS ordered_multiset implementation TLE’d twice. This post covers how Red-Black trees and order statistics work, and why a Fenwick tree passed instead.

July 5, 2026 · 18 min · Priyanshu Debnath