前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Codeforces Round #622 (Div. 2) 1313 B Different Rules

Codeforces Round #622 (Div. 2) 1313 B Different Rules

作者头像
风骨散人Chiam
发布2020-10-29 09:47:53
3020
发布2020-10-29 09:47:53
举报
文章被收录于专栏:CSDN旧文

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的所有情况,就懂了怎么做了。凑数都能凑出来。

代码语言:javascript
复制
#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;
        }
    }
}
在这里插入图片描述
在这里插入图片描述

真的是B题题解。

在这里插入图片描述
在这里插入图片描述

末尾是个!截图没弄好,就是判断哪一些在范围内!

在这里插入图片描述
在这里插入图片描述

写在最后: 我叫风骨散人,名字的意思是我多想可以不低头的自由生活,可现实却不是这样。家境贫寒,总得向这个世界低头,所以我一直在奋斗,想改变我的命运给亲人好的生活,希望同样被生活绑架的你可以通过自己的努力改变现状,深知成年人的世界里没有容易二字。目前是一名在校大学生,预计考研,热爱编程,热爱技术,喜欢分享,知识无界,希望我的分享可以帮到你! 如果有什么想看的,可以私信我,如果在能力范围内,我会发布相应的博文! 感谢大家的阅读!?你的点赞、收藏、关注是对我最大的鼓励!

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020/02/23 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 末尾是个!截图没弄好,就是判断哪一些在范围内!
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档