RMI

Time limit: 0.7s Memory limit: 256MB Input: Output:

Rising Minds in Informatics (RMI) is a two-day competition aimed at discovering and nurturing young talents in the field of computer science and informatics.

As a participant of RMI, you would like to estimate your final rank before the award ceremony. The overall scoreboard has not been released yet, but you have the scores of all contestants for each day separately, without knowing which score belongs to whom. You also know your own scores for both days.

Task

Your task is to determine:

  • Best possible place: The highest rank you could achieve based on the sum of scores, assuming the most favorable pairing of scores for you.
  • Worst possible place: The lowest rank you could achieve based on the sum of scores, assuming the least favorable pairing of scores for you.

What are your best and worst possible ranks in the combined total score standings? Ties (draws) are allowed, meaning multiple contestants with the same total score will share the same rank. In other words, if KK participants have a strictly greater score than you: you will be considered the (K+1)(K{+}1)-th.

Input data

The first line contains 3 integers AA, BB, NN, where AA is your score for the first day, BB is your score for the second day and there are NN participants excluding you.

The second line contains NN integers FiF_i, the scores of the other participants for the first contest day (please note that your score is not included in this list).

The third line contains NN integers SiS_i, the scores of the other participants for the second contest day (please note that your score is not included in this list).

Output data

You need to write a single line with two integers: your best possible rank and your worst possible rank.

Constraints and clarifications

  • 1N100 0001 \le N \le 100 \ 000
  • 0A,B,Fi,Si1 000 000 0000 \le A,B,F_i,S_i \le 1 \ 000 \ 000 \ 000 for each i=0N1i=0\ldots N-1.
  • In each subtask, you can get partial scores. You will get 50%50\% of the points for a subtask if you successfully determine your best possible rank in every test case, but the value of the worst possible rank is incorrect at least once. To obtain the partial score, make sure that the output of your program conforms to the output specification above, otherwise, the checker might reject your solution due to formatting error.
# Points Constraints
1 0 Examples
2 30 N9N \leq 9. A,B,Fi,Si100A,B, F_i, S_i \leq 100 for each i=0N1i = 0 \ldots N − 1.
3 20 N100N \leq 100. A,B,Fi,Si1 000A,B, F_i, S_i \leq 1 \ 000 for each i=0N1i = 0 \ldots N − 1.
4 50 No additional constraints.

Example 1

stdin

100 200 2
200 200
100 100

stdout

1 1

Explanation

Everyone has a combined score of 300300 points. There is a draw in the first place.

Example 2

stdin

200 100 3
100 150 200
200 100 150

stdout

1 3

Explanation

Since 150+150=100+200=200+100=300150+150=100+200=200+100=300, you can be ranked first. But if you are not that lucky, you can end up in the third place as 150+200=200+150>300>100+100150+200=200+150>300>100+100. It can be proven, that you can not finish fourth.

Example 3

stdin

200 100 9
100 150 200 310 0 120 160 140 180
100 150 310 0 80 100 100 140 120

stdout

2 6

Log in or sign up to be able to send submissions!