VisaOA #17
Maximize Capped Contribution Sum
Estimated EasyJudge-ready
Topics (AI-labelled)Greedy
The initial value is Σmin(a[i],b[i]); you may choose at most k distinct positions and change b[i] there to 2b[i]. Find the maximum total.
Input
n,k (1≤n≤200000, 0≤k≤n), followed by two lines of n integers each, in the range −10⁹..10⁹ (site-added; negative numbers are allowed).
Output
Output the maximum total, using a 64-bit integer.
Example 1
Input:
3 2
10 8 6
3 6 10
Output:
20
Example 2
Input:
2 2
5 5
10 10
Output:
10
Example 3
Input:
2 1
-5 4
3 -3
Output:
-8
Editorial
Loading solution…