[Solution] Optimal Reduction solution codeforces

Optimal Reduction solution codeforces – Consider an array 𝑎a of 𝑛n positive integers. You may perform the following operation: select two indices 𝑙l and 𝑟r (1≤𝑙≤𝑟≤𝑛1≤l≤r≤n), then decrease all elements 𝑎𝑙,𝑎𝑙+1,…,𝑎𝑟al,al+1,…,ar by 11. [Solution] Optimal Reduction solution codeforces Let’s call 𝑓(𝑎)f(a) the minimum number of operations needed to change array 𝑎a into an array of 𝑛n zeros. Determine if for all permutations†† 𝑏b of 𝑎a, 𝑓(𝑎)≤𝑓(𝑏)f(a)≤f(b) is true. †† An array 𝑏b is a permutation of an array 𝑎a if 𝑏b consists of … Read more