Company: AT&T_12thjuly
Difficulty: medium
Partition Computational Units A machine learning cluster owns n computational units in a fixed row. Unit i has capacity storage[i] . The units must be handed out to exactly k models, and a model always receives a contiguous block of the row, so the row is cut into k consecutive non-empty blocks that together cover all n units. A model that receives a block of length m only runs if the capacities inside that block are exactly 1, 2, ..., m in some order — a permutation of 1..m . Any unit inside a block may be replaced by a unit of any capacity you like; one replaced unit costs one operation. Let minOp be the smallest total number of replacements over all ways of cutting the row into k blocks. Report the block lengths of a cut that achieves minOp . If several cuts achieve minOp , report the lexicographically smallest list of lengths modelCap . Input Format The first line contains an integer n , the number of computational units. Each of the next n lines contains an integer storage[i] . Th