#P10355. [PA 2024] Znaczki pocztowe
[PA 2024] Znaczki pocztowe
Background
PA 2024 2C
Problem Description
This problem is translated from PA 2024 Round 2 Znaczki pocztowe.
Byteasar once collected a large number of postage stamps. However, he is no longer as interested in stamps as he was when he was young, so he decided to give his collection to younger stamp collectors. Still, he wants to do this as fairly as possible, so he needs your help.
Byteasar's collection consists of stamps, where the -th stamp comes from city . For simplicity, we represent cities using integers. Byteasar plans to publish an announcement in a newspaper saying that he intends to give away the stamps from his collection. If there are people willing to receive them, he will give each person a subset of stamps under the following condition: everyone must receive the same multiset of stamps. This means that for any two applicants and for any city, both applicants must receive the same number of stamps from that city. In particular, this may mean that Byteasar gives away no stamps at all.
Byteasar does not know how many people will show up. Therefore, for each from to , you need to determine the maximum number of stamps Byteasar can give away if there are people willing to receive them.
Input Format
The first line contains an integer , the number of stamps in Byteasar's collection.
The second line contains integers , where is the city number of the -th stamp.
Output Format
Output one line with integers. The -th integer should be the maximum number of stamps Byteasar can give away if there are people willing to receive his stamps.
9
1 1 777 42 777 1 42 1 777
9 8 6 4 0 0 0 0 0
Hint
If there is one person willing to receive them, Byteasar can give him all the stamps.
If there are two people, Byteasar can give each of them two stamps from city , one stamp from city , and one stamp from city , for a total of stamps.
If there are four people, Byteasar can give each of them one stamp from city .
If the number of people willing to receive them is greater than four, Byteasar will not be able to give away any stamps.
Translated by ChatGPT 5