Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be n participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of the traditional rules, in which the participant who solved the largest number of problems wins, the organizers came up with different rules.
Suppose in the first round participant A took x-th place and in the second round — y-th place. Then the total score of the participant A is sum x+y. The overall place of the participant A is the number of participants (including A) having their total score less than or equal to the total score of A. Note, that some participants may end up having a common overall place. It is also important to note, that in both the first and the second round there were no two participants tying at a common place. In other words, for every i from 1 to n exactly one participant took i-th place in first round and exactly one participant took i-th place in second round.
Right after the end of the Olympiad, Nikolay was informed that he got x-th place in first round and y-th place in the second round. Nikolay doesn’t know the results of other participants, yet he wonders what is the minimum and maximum place he can take, if we consider the most favorable and unfavorable outcome for him. Please help Nikolay to find the answer to this question.
Input
The first line contains an integer t (1≤t≤100) — the number of test cases to solve.
Each of the following t lines contains integers n, x, y (1≤n≤109, 1≤x,y≤n) — the number of participants in the olympiad, the place that Nikolay took in the first round and the place that Nikolay took in the second round.
Output
Print two integers — the minimum and maximum possible overall place Nikolay could take.
Examples
inputCopy
1
5 1 3
outputCopy
1 3
inputCopy
1
6 3 4
outputCopy
2 6
Note
Explanation for the first example:
Suppose there were 5 participants A-E. Let’s denote Nikolay as A. The the most favorable results for Nikolay could look as follows:
However, the results of the Olympiad could also look like this:
In the first case Nikolay would have taken first place, and in the second — third place.
题意:
一场比赛分两轮,每一轮你都有一个排名(注意每一轮的排名不能出现并列)。最终的排名就是两轮排名相加之后所排在第几个就是第几名。
问最高排名和最低排名
解析:
最低排名很好算
引用这个博主的图:https://blog.csdn.net/Doneoll/article/details/104481023
就是让尽可能多的人和我的名次一样
x y的取值就为 1~(x+y-1)
所以最低名次为min(x+y-1,n)
最高名次
两种情况
第一种:(x+y<=n)
按照这种以下这种方式排列,那么一定能排在第一名
第二种:(x+y>n)
当某一轮为1~(x+y-n)的人无论如何分配都无法让他的排名高于我们,所以我们让低名次继续低下去。所以按照下图的方法分配(如果某轮排名为1 ~(x+y-n),那么另一轮的排名和他一样即可)
假设我前面有t人
x-t+y-t=n-t
t=x+y-n
那么排名就是min(x+y-n+1,n);
#include<bits/stdc++.h>
using namespace std;
int t;
int n,x,y;
int main()
{
cin>>t;
while(t--)
{
cin>>n>>x>>y;
int l,r;
r=min(x+y-1,n);
if(x+y<=n) l=1;
else l=min(x+y-n+1,n);
cout<<l<<" "<<r<<endl;
}
}