CF1846A.Rudolph and Cut the Rope
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are n nails driven into the wall, the i-th nail is driven ai meters above the ground, one end of the bi meters long rope is tied to it. All nails hang at different heights one above the other. One candy is tied to all ropes at once. Candy is tied to end of a rope that is not tied to a nail.
To take the candy, you need to lower it to the ground. To do this, Rudolph can cut some ropes, one at a time. Help Rudolph find the minimum number of ropes that must be cut to get the candy.
The figure shows an example of the first test:

墙上钉有 n 颗钉子,第 i 颗钉子距地面高度为 ai 米,一根长度为 bi 米的绳子一端系在该钉子上。所有钉子彼此高度不同,自上而下依次排列。一颗糖果被同时系在所有绳子的自由端(即未系在钉子上的那一端)。
要取到糖果,需将其降至地面。为此,鲁道夫可逐次剪断若干根绳子。请帮助鲁道夫找出为取到糖果所必须剪断的最少绳子数量。
下图展示了第一个测试用例的示意图:

输入格式
The first line contains one integer t (1≤t≤104) — the number of test cases.
The first line of each test case contains one integer n (1≤n≤50) — the number of nails.
The i-th of the next n lines contains two integers ai and bi (1≤ai,bi≤200) — the height of the i-th nail and the length of the rope tied to it, all ai are different.
It is guaranteed that the data is not contradictory, it is possible to build a configuration described in the statement.
第一行包含一个整数 t(1≤t≤104)—— 测试用例的数量。
每个测试用例的第一行包含一个整数 n(1≤n≤50)—— 钉子的数量。
接下来的 n 行中,第 i 行包含两个整数 ai 和 bi(1≤ai,bi≤200)—— 第 i 个钉子的高度以及系在该钉子上的绳子的长度;所有 ai 互不相同。
保证输入数据不矛盾,即一定可以构造出题目描述中的配置。
输出格式
For each test case print one integer — the minimum number of ropes that need to be cut to make the candy fall to the ground.
对于每个测试用例,输出一个整数——使糖果落到地面所需剪断的绳子的最少数量。
输入输出样例
输入#1
4 3 4 3 3 1 1 2 4 9 2 5 2 7 7 3 4 5 11 7 5 10 12 9 3 2 1 5 3 5 6 4 5 7 7
输出#1
2 2 3 0
输入解题思路,AI测评打分。不知道怎么写?