Drumpf for President!
All submissions for this problem are available.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Donald Drumpf has spent the entire summer lobbying to gather votes for the upcoming student government election. At his University, there are a total of N students. Each student in the university casts a vote. The size of student government is determined by the number of students that get at least K votes.
Each person that receives at least K votes is given a post in the student government. The Dean noticed that every year, there are a few students who vote for themselves. He decided to add a rule to disqualify any such individuals who vote for themselves i.e they cannot be part of the student government.
You are given an array A, where Ai denotes the person who the i-th person voted for. Can you compute the size of the student government?
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
For each test case, first line consists of two space separated integers N, K.
Second line consists of N space separated integers denoting the array A, where i-th integer denotes Ai.
For each test case, output a single line containing an integer corresponding to the size of the student government.
- 1 ≤ T ≤ 100
- 1 ≤ K ≤ N
- 1 ≤ Ai ≤ N
SubtasksSubtask #1: (30 points)
- 1 ≤ N ≤ 3
- 1 ≤ N ≤ 100
Input: 2 3 2 2 1 2 2 1 1 2 Output: 1 0
In first test case, there are 3 students. A student must receive at least 2 votes to be part of the student government. Student 1 votes for student 2, student 2 votes for student 1 and student 3 votes for student 2. Thus, Student 2 receives 2 votes and is the only one eligible for student government.
In second test case, although both students receive the required amount of votes, they are both disqualified as they had voted for themselves. Thus, size of the student government is 0.
|Tags||ad-hoc, admin2, cakewalk, ltime38|
|Time Limit:||2 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.