Phineas goes to school after the lockdown is over and finds out that all his N−1N−1 friends have turned into bullies. So he himself too starts disliking his friends. The teacher Dr Doof wants to distribute MM marks to his NN students (including Phineas). Dr Doof is busy in his experiments and so wants the students to distribute MM marks among themselves such that each student gets a non negative integer marks or gets expelled. So he makes a plan. He makes all of his NN students stand in an line and then the NthNth student is made the leader. The task of the leader is to propose the distribution of MM marks among all the students present. Then a voting is carried out and all present students ( including the leader) can vote either for or against the distribution.
Phineas goes to school after the lockdown is over and finds out that all his N−1N−1 friends have turned into bullies. So he himself too starts disliking his friends. The teacher Dr Doof wants to distribute MM marks to his NN students (including Phineas). Dr Doof is busy in his experiments and so wants the students to distribute MM marks among themselves such that each student gets a non negative integer marks or gets expelled. So he makes a plan.
He makes all of his NN students stand in an line and then the NthNth student is made the leader. The task of the leader is to propose the distribution of MM marks among all the students present. Then a voting is carried out and all present students ( including the leader) can vote either for or against the distribution.
- If the distribution is voted for by at least 50%50% of the students present, then it is is approved with the leader becoming the deciding student and the process ends.
- Otherwise the last KK present students are expelled ( including the leader ). and the (N−K)th(N−K)th student is appointed as the new leader and the process is repeated.
If there are ≤K≤K students left and the distribution is not approved, then all the present students will get expelled.
Following are the characteristics of each of the NN students and everyone knows about it.
- Everyone wants to maximize the marks they get or at least try not to get expelled (i.e. every student prefers getting 00 marks over getting expelled).
- Each of them have turned into bullies ( including Phineas ) and so given a choice of getting the same marks and expel more students, then they would go for it.
- If there are multiple distribution proposals maximizing the leader's marks that would be accepted (voted for by atleast 50%50% of the students) then he will propose the lexicographically smallest such distribution.
( As an example: If N=6,M=10N=6,M=10 and (0,0,4,1,0,5)(0,0,4,1,0,5), (0,3,0,0,2,5)(0,3,0,0,2,5) and (2,3,0,0,0,5)(2,3,0,0,0,5) are the possible proposals that will be accepted, and 5 is the maximum marks the leader can get, then he'll propose (0,0,4,1,0,5)(0,0,4,1,0,5)) - Each of them are brilliant logical thinkers.
Phineas is confused and wants your help to know at what position he must stand so that he will be the deciding student if everyone thinks optimally and what maximum marks can he get being at that position.
Input:
1
4 1 2
Output:
4 1
Step by step
Solved in 3 steps with 1 images