Want to try solving this problem? You can submit your code online if you log in or register.

When you were young, you were awe-struck by the battle scene in The Lord of the Rings: The Two Towers. From then on, you were determined to become the greatest archer of all time. After years of training, you are finally at the International Archery Olympiad (IAO), in Auckland.

On each of the two days of the IAO, all contestants are given a score and ranked by that score. After the second day of competition, all contestants are given an overall score equal to the sum of their two scores and their overall rank is then calculated from this.

Katniss | Legolas | Link | Merida | Robin | |

Day 1 Score |
50 | 70 | 20 | 40 | 0 |
---|---|---|---|---|---|

Day 1 Rank |
2 | 1 | 4 | 3 | 5 |

Day 2 Score |
30 | 20 | 40 | 50 | 40 |

Day 2 Rank |
4 | 5 | 2 | 1 | 2 |

Overall Score |
80 | 90 | 60 | 90 | 40 |

Overall Rank |
3 | 1 | 4 | 1 | 5 |

A contestant's rank is equal to the number of competitors with strictly greater scores than theirs, plus one. In the above example, there are two overall scores strictly greater than Katniss's, so her overall rank is (2+1)=3. There are no overall scores strictly greater than Legolas's, so his overall rank is (0+1)=1. (Notice that Legolas and Merida are both ranked 1, as no one has a strictly greater score than either of them.)

Sick with anticipation of the results, you sneak a look at a judge's laptop. The scores aren't shown, nor is your overall rank, but you do manage to glimpse your first-day rank and your second-day rank. You want to work out what your overall rank could be.

Your task is to write a program which, given the number of contestants in the IAO and your rank on each day, determines your best and worst possible overall rank.

Your program should read from the file . The first and only line of input will contain three space-separated integers in this order:

- N: the total number of contestants in the IAO (including you)
- A: your rank on just the first day (between 1 and N)
- B: your rank on just the second day (between 1 and N)

Your program should write to the file . Your output file should contain one line with two integers, with exactly one space between them. The first integer is your best (i.e. smallest number) possible overall rank and the second integer is your worst (i.e. largest number) possible overall rank.

4 1 3

1 3

In this example, there are four contestants (including you), and you have rank 1 and 3 on the first and second days respectively. Here's one possible set of scores in which you have rank 1:

You | Katniss | Link | Merida | |

Day 1 Score |
100 | 20 | 10 | 0 |
---|---|---|---|---|

Day 1 Rank |
1 | 2 | 3 | 4 |

Day 2 Score |
20 | 30 | 50 | 10 |

Day 2 Rank |
3 | 2 | 1 | 4 |

Overall Score |
120 | 50 | 60 | 10 |

Overall Rank |
1 | 3 | 2 | 4 |

On the other hand, if your Day 1 score in the above table was 25 instead, you would have an overall rank of 3. There is no set of scores consistent with your Day 1 and Day 2 ranks such that you come last.

Thus, your best possible rank is 1, and your worst possible rank is 3.

4 1 1

1 1

Since you came first on both days, you must have come first overall (no one could have got a strictly better score than you).

10 5 8

3 10

To evaluate your solution, the judges will run your program against several different input files. All of these files will adhere to the following bounds:

- 1 ≤ N ≤ 1,000 (the number of contestants in the IAO)
- 1 ≤ A ≤ N (your rank on the first day)
- 1 ≤ B ≤ N (your rank on the second day)

Privacy
statement

© Australian Mathematics Trust 2001-2016

Page generated: 23 July 2016, 11:02pm AEST