A13340 | Different Rules
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
The first line contains an integer $t$ ( $1 \le t \le 100$ ) — the number of test cases to solve.
Each of the following $t$ lines contains integers $n$ , $x$ , $y$ ( $1 \leq n \leq 10^9$ , $1 \le x, y \le 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.
Each of the following $t$ lines contains integers $n$ , $x$ , $y$ ( $1 \leq n \leq 10^9$ , $1 \le x, y \le 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.
输出格式
Print two integers — the minimum and maximum possible overall place Nikolay could take.
输入输出样例
输入 #1
1 5 1 3
输出 #1
1 3
输入 #2
1 6 3 4
输出 #2
2 6
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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted