← 返回 ramp 的题目列表Maximum Earnings After Converting Days Off to Workdays
类型:online_judge
Problem: Maximum Earnings After Converting Days Off to Workdays
An employee plans their work schedule for the next n days. The schedule is represented by a binary string s of length n:
s[i] = '1' means day i is originally a workday;
s[i] = '0' means day i is originally a day off.
For each workday, the employee earns pay dollars.
Additionally, if a day is a workday and the previous day is also a workday, the employee earns an extra bonus dollars on that day.
The employee may change at most k days off into workdays, i.e. flip at most k characters from '0' to '1'. Return the maximum possible total earnings over the n days.
Input Format
n k
pay bonus
s
Output Format
Print one integer: the maximum possible total earnings.
Constraints
1 <= n <= 2 * 10^5
0 <= k <= n
1 <= pay, bonus <= 10^9
s.length == n
s contains only '0' and '1'
Example 1
5 1
10 5
10101
Output:
50
Example
Input
5 1
10 5
10101
Output
50