Dividing an orange
Time limit1sMemory limit1024 MB
For each wildcard rank, find the minimum and maximum number of oranges that person can get in the ranked voting game with n people and k oranges.
- Level
Hard8 of 10
- Topics
- Game theory, Math, Recursion
- Solved
- No attempts yet
Problem
On a faraway planet i1c5l, a community of people harvested oranges. Now they have to divide the harvest among themselves.
The community is ruled by a democratic principle based on rank. The harvest is divided as follows. Each person gets a rank from 1 to . The person ranked 1 announces a decision: who gets how many oranges. Then all people vote "for" or "against". If at least half of the people vote "for", the decision is accepted. Otherwise the person ranked 1 is ostracized from the community, the person ranked 2 announces a decision, and the procedure repeats.
Each person wants to get as many oranges as possible for himself. Between cases with equal amounts of oranges, he prefers the one with fewer people left in the community. A person who is ostracized is considered to have received a negative amount of oranges. If several optimal solutions exist, a person can choose any of them. Each person knows that the others also look for an optimal solution guided by the same principles.
However, one member of the community has wildcards, and each one gives him a predefined rank. For each wildcard rank, find the minimum and maximum number of oranges he can obtain.
Input
The first line contains integers , , and (, ), the number of people, the number of oranges, and the number of wildcards. The second line contains integers (), where is the rank given by the -th wildcard.
Output
For each , print the minimum and maximum number of oranges the wildcard owner can obtain on a separate line. Print "-1 -1" if he is ostracized.
Hint
In the first example, the person ranked 1 takes all the oranges and votes "for".
In the second example, the person ranked 1 must give the orange to the person ranked 3. If the first person takes one orange, the rest vote "against". If he gives the orange to the second person, the second also votes "against", because he knows that ostracizing the first leads to an orange for them too, but with fewer people left. Since the third person also votes "against", this option is not available to the first person.