Algorithms
3886. Sum of Sortable Integers
Rotation sounds like freedom and gives you none. If some cyclic shift of a length-k block is non-decreasing, that shift is exactly the sorted order of the block's multiset, so the block's final contents are fixed before you choose anything. Two questions are left: does each block admit such a shift at all, and do the blocks already sit in the right order relative to each other.
Loading…