Back to problems

Minimum Sum After K Operations

Algorithm · NVIDIA · Medium

You are given an integer array a containing n values, along with an integer k. Apply precisely k updates so that the array's resulting total is as small as possible. For each update: Select any position i, then set a[i] to ceil(a[i] / 2). Print the smallest sum obtainable once all k updates have been used. Input (stdin): Line 1 contains n k. Line 2 contains n integers. Output (stdout): Print one integer: the least possible final array sum. Constraints: 1 <= n <= 2e5, 0 <= k…

Checking your access…