시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB114715864.444%

문제

One well-known joke goes as follows: If a bad Computer Science student drops out of college and goes to a different college to study Economics instead, he will increase the average intelligence on both colleges.

In this problem we will investigate the maths behind this joke.

Given the list of student IQs for each of the two colleges, find the number of students of Computer Science that can make the joke true – that is, compute the size of the set { S | S is a student of Computer Science, and if he went to study Economics, both average IQs would increase }.

입력

The first line of the input file contains an integer T specifying the number of test cases. Each test case is preceded by a blank line.

Each test case looks as follows: The first line two positive integers NCS and NE – the number of students of Computer Science and Economics, respectively. The number of Computer Science students will be at least 2.

The following lines contain a total of NCS+NE whitespace-separated non-negative integers giving the IQs of all the students. The first NCS students mentioned in the input are Computer Science students, the remaining ones study Economics.

출력

For each test case output a single line with a single integer – the number of Computer Science students that would cause the funny event to happen.

제한

  • 1 ≤ T ≤ 12
  • All IQs are non-negative integers that are less than 100,000.

서브태스크

번호배점제한
Easy1

1 ≤ NCS, NE ≤ 1,000

Hard2

1 ≤ NCS, NE ≤ 200,000

예제 입력 1

1

5 5
100 101 102 103 104
98 100 102 99 101

예제 출력 1

1

힌트

The average Computer Science IQ increases only if the leaving student is #1 or #2. Student #1 is too dumb to raise the average IQ for Economics, thus only student #2 remains and the answer is 1.

채점 및 기타 정보

  • 예제는 채점하지 않는다.