#BS0000355. Nâng cấp kỹ năng (Skills)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Nâng cấp kỹ năng (Skills)
Skills
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Lesha is playing a new version of hacknet. His character has skills, numbered from to . Skill starts at level , and all skills share the maximum level .
The ranking uses a strength value. For final levels , this value is
$$F=c_f\cdot |\{i:b_i=A\}|+c_m\cdot\min_{1\le i\le n}b_i.$$The nonnegative coefficients reward the number of fully upgraded skills and the lowest skill level, respectively.
Lesha has currency units. One unit raises any chosen skill by provided it is below . Spending the entire budget is optional.
Find the highest attainable strength and one corresponding sequence of final levels.
Input
The first line contains five integers : the number of skills, the maximum level, the two strength coefficients and the available budget.
The second line contains exactly integers , the initial levels in skill order.
Output
Print the maximum strength on the first line.
On the second line print integers in skill order, satisfying for every and . Their strength must equal the value on the first line. Any optimal sequence is accepted.
Subtasks
- Subtask 1 (20 points): ; ; ; ; for every .
- Subtask 2 (30 points): ; ; ; ; for every .
- Subtask 3 (50 points): ; ; ; ; for every .
Examples
Input 1
3 5 10 1 5
1 3 1
Output 1
12
2 5 2
Explanation
Raise the second skill from to for units and each other skill from to for another . Strength is . Two perfect skills cost at least . With one perfect skill, reaching minimum costs at least . With no perfect skills the strength is at most .
Input 2
3 5 10 1 339
1 3 1
Output 2
35
5 5 5
Explanation
Making every skill level costs , within . Strength is , the upper bound since there are only three skills and the minimum level cannot exceed .