#P2072. 宗教问题
宗教问题
Description
It is known that there are religions (numbered ) and believers (numbered ), and each believer believes in exactly one religion.
Now you need to split these believers, in order, into several groups. The danger value of a group is defined as the number of distinct religions in that group, and a group may not contain more than religions; otherwise it is infinitely dangerous.
Problem:
- Into how many groups at least must these believers be divided?
- What is the minimum possible sum of the danger values of these groups?
Input Format
The first line contains three positive integers , separated by spaces.
The second line contains positive integers, the religion number of each believer.
Output Format
The first line contains one positive integer, the minimum number of groups.
The second line contains one positive integer, the minimum total danger value.
10 4 3
1 2 3 4 3 4 3 2 1 2
3
6
Hint
Sample explanation:
One optimal partition is:
Constraints:
For of the testdata, .
For of the testdata, .
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号