Codeforces Round 733 (Div. 1 + Div. 2, based on VK Cup 2021 - Elimination (Engine)) E. Minimax
3013. Divide an Array Into Subarrays With Minimum Cost II
You are given a 0-indexed array of integers
numsof lengthn, and two positive integerskanddist.The cost of an array is the value of its first element. For example, the cost of
[1,2,3]is1while the cost of[3,4,1]is3.You need to divide
numsintokdisjoint contiguous subarrays, such that the difference between the starting index of the second subarray and the starting index of thekthsubarray should be less than or equal todist. In other words, if you dividenumsinto the subarraysnums[0..(i1 - 1)], nums[i1..(i2 - 1)], ..., nums[ik-1..(n - 1)], thenik-1 - i1 <= dist.Return the minimum possible sum of the cost of these subarrays.
3012. Minimize Length of Array Using Operations
You are given a 0-indexed integer array
numscontaining positive integers.Your task is to minimize the length of
numsby performing the following operations any number of times (including zero):
- Select two distinct indices
iandjfromnums, such thatnums[i] > 0andnums[j] > 0.- Insert the result of
nums[i] % nums[j]at the end ofnums.- Delete the elements at indices
iandjfromnums.Return an integer denoting the minimum length of
numsafter performing the operation any number of times.
3011. Find if Array Can Be Sorted
You are given a 0-indexed array of positive integers
nums.In one operation, you can swap any two adjacent elements if they have the same number of set bits. You are allowed to do this operation any number of times (including zero).
Return
trueif you can sort the array, else returnfalse.
3010. Divide an Array Into Subarrays With Minimum Cost I
You are given an array of integers
numsof lengthn.The cost of an array is the value of its first element. For example, the cost of
[1,2,3]is1while the cost of[3,4,1]is3.You need to divide
numsinto3disjoint contiguous subarrays.Return the minimum possible sum of the cost of these subarrays.