CF1187A.Stickers and Toys
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Your favorite shop sells n Kinder Surprise chocolate eggs. You know that exactly s stickers and exactly t toys are placed in n eggs in total.
Each Kinder Surprise can be one of three types:
- it can contain a single sticker and no toy;
- it can contain a single toy and no sticker;
- it can contain both a single sticker and a single toy.
But you don't know which type a particular Kinder Surprise has. All eggs look identical and indistinguishable from each other.
What is the minimum number of Kinder Surprise Eggs you have to buy to be sure that, whichever types they are, you'll obtain at least one sticker and at least one toy?
Note that you do not open the eggs in the purchasing process, that is, you just buy some number of eggs. It's guaranteed that the answer always exists.
你最喜爱的商店出售 n 个 Kinder Surprise 巧克力蛋。已知这 n 个蛋中总共恰好包含 s 张贴纸和 t 个玩具。
每个 Kinder Surprise 蛋属于以下三种类型之一:
- 仅含一张贴纸,不含玩具;
- 仅含一个玩具,不含贴纸;
- 同时含一张贴纸和一个玩具。
但你并不知道某个具体的 Kinder Surprise 蛋属于哪一种类型。所有蛋外观完全相同,无法区分。
为了确保无论这些蛋的具体类型如何分配,你都能至少获得一张贴纸和一个玩具,你最少需要购买多少个 Kinder Surprise 蛋?
注意:你在购买过程中不会打开蛋,即你只是购买一定数量的蛋。题目保证答案一定存在。
输入格式
The first line contains the single integer T (1≤T≤100) — the number of queries.
Next T lines contain three integers n, s and t each (1≤n≤109, 1≤s,t≤n, s+t≥n) — the number of eggs, stickers and toys.
All queries are independent.
第一行包含一个整数 T(1≤T≤100),表示查询次数。
接下来 T 行,每行包含三个整数 n、s 和 t(1≤n≤109,1≤s,t≤n,s+t≥n),分别表示鸡蛋数量、贴纸数量和玩具数量。
所有查询相互独立。
输出格式
Print T integers (one number per query) — the minimum number of Kinder Surprise Eggs you have to buy to be sure that, whichever types they are, you'll obtain at least one sticker and one toy
输出 T 个整数(每个查询输出一个数)——为确保无论买到的蛋是什么类型,都能至少获得一张贴纸和一个玩具,你需要购买的 Kinder Surprise 鸡蛋的最少数量。
输入输出样例
输入#1
3 10 5 7 10 10 10 2 1 1
输出#1
6 1 2
说明/提示
In the first query, we have to take at least 6 eggs because there are 5 eggs with only toy inside and, in the worst case, we'll buy all of them.
In the second query, all eggs have both a sticker and a toy inside, that's why it's enough to buy only one egg.
In the third query, we have to buy both eggs: one with a sticker and one with a toy.
在第一次查询中,我们必须至少购买 6 个鸡蛋,因为其中有 5 个鸡蛋仅包含玩具,而在最坏情况下,我们会买下全部这 5 个鸡蛋。
在第二次查询中,所有鸡蛋内部都同时包含贴纸和玩具,因此只需购买一个鸡蛋即可。
在第三次查询中,我们必须购买两个鸡蛋:一个包含贴纸,另一个包含玩具。
输入解题思路,AI测评打分。不知道怎么写?