#GD0000169. Polycarp ở đài phát thanh (Polycarp at the Radio)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Polycarp ở đài phát thanh (Polycarp at the Radio)
Polycarp at the Radio
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
A playlist has songs, with band ID for each song. Polycarp cares about bands through . Changing the performer at one position costs one edit. First maximize the minimum frequency among these bands, then minimize the number of edits. Output an optimal playlist.
Input
The first line contains . The second contains integer band identifiers .
Output
Print the maximum minimum frequency and the minimum required number of edits. On the next line print the resulting band IDs.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
4 2
1 2 3 2
Output
2 1
1 2 1 2
Explanation
Each of bands and can receive two songs, reaching the upper bound . Changing the third song from band to band gives , with counts and only one edit; zero edits would leave band underrepresented.