Codeforces 题记 Different Rules
  TEZNKK3IfmPf 2023年11月14日 17 0

B. Different Rules


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


这个题比较简单,画一个5的所有情况,和6的所有情况,就懂了怎么做了。凑数都能凑出来。

#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
for (int i = 0; i < t; i++)
{
int a, b, c;
cin >> a >> b >> c;
if (a == 1)
cout << 1 <<" "<<1<< endl;
else{
cout << max(1, min(a, b + c - a + 1)) << " ";
if (b + c - 1 >a)
cout << a << endl;
else
cout << min(a, a - (abs(a - b + 1 - c))) << endl;
}
}
}

Codeforces 题记 Different Rules


【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月14日 0

暂无评论

推荐阅读
  TEZNKK3IfmPf   22天前   34   0   0 C++
  TEZNKK3IfmPf   22天前   24   0   0 指针C++
  TEZNKK3IfmPf   2024年05月31日   24   0   0 算法C++
TEZNKK3IfmPf