No.568 JanJan Otosu Iinkai (Keep-Rejecting Committee)
タグ : / 解いたユーザー数 63
作問者 :
WA_TLE
/ テスター :
Problem Statement
JOI (JanJan Otosu Iinkai) appears to be conducting a selection for some kind of training camp.
This contest does not take into account the time at which problems were solved or the number of WAs at all, so simply the number of fully solved problems matters.
Currently, 3 of the problems for the final round have been decided, but only the 2 problems A and B remain undecided.
The difficulty of each of the 2 problems can be independently set to an integer between 0 and 100001, inclusive.
There are n participants in the final round held by JOI. (1<=n<=100000)
Since the camp has no budget, the committee wants to adjust the difficulties of the remaining 2 problems skillfully
so that the number of people who fully solve at least 2 problems is at least m, while minimizing the number of people who fully solve at least 3 problems. (1<=m<=n)
From each person's abilities, (Xi,Ai,Bi) is given. (0<=Xi<=3,0<=Ai , Bi<=100000)
Xi is the number of the already decided problems that the person can fully solve.
Ai means that, when the overall difficulty of problem A is SA, the person can fully solve it if Ai>=SA.
Bi means that, when the overall difficulty of problem B is SB, the person can fully solve it if Bi>=SB.
Output the number of people who fully solve at least 3 problems in that case.
*This problem is fiction. It has no relation whatsoever to any real organizations or persons.
Input
N M xi ai bi
Output
Print a newline at the end.
Sample
Sample 1
Input
10 5 1 2 5 2 4 6 2 3 5 0 1 3 3 2 2 0 1 4 0 5 1 1 2 1 0 6 7 1 4 4
Output
2
For example, it works well to set the difficulty of A to 4 and the difficulty of B to 7.
Sample 2
Input
34 24 2 11 10 0 0 9 1 0 3 0 4 9 3 5 4 1 10 5 1 5 3 0 2 6 2 6 8 0 9 8 3 3 6 0 1 11 1 4 6 0 2 2 0 6 11 2 10 10 3 7 11 3 11 6 3 0 0 2 3 10 0 2 2 2 8 7 0 3 11 3 11 9 0 1 0 0 9 7 1 9 5 1 8 5 2 9 1 0 10 9 2 6 6 0 6 6 2 1 5 2 6 1
Output
14
For example, if the difficulty of A is 2 and the difficulty of B is 9, 24 people fully solve at least 2 problems, and 14 people fully solve at least 3 problems.
In other words, solving just 2 problems will not get you to the camp. How sad. (Side note)
Sample 3
Input
5 2 3 1 3 2 1 4 3 4 2 1 2 3 3 4 6
Output
3
Yes.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。