atcoder#ARC147E. [ARC147E] Examination
[ARC147E] Examination
Score : points
Problem Statement
students, numbered , took an examination. Student had to score at least points to graduate, where they actually scored points.
You can repeat the following operation any number of times (possibly zero):
- Choose two students, and swap their scores.
Your goal is to make everyone graduate. Determine whether it is possible. If it is possible, find the maximum number of students whose scores do not change during the process.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
If it is possible to make everyone graduate, print the maximum number of students whose scores do not change during the process.
Otherwise, print -1
.
3
1 2
3 1
3 3
1
If you swap scores of Student and , everyone can graduate. Here, the number of students whose scores do not change is (only Student ).
2
100 1
100 1
2
6
3 2
1 6
4 5
1 3
5 5
9 8
-1
6
3 1
4 5
5 2
2 3
5 4
5 1
3