题库练习 Contest Balloons
← 上一题 下一题 →

A10616 | Contest Balloons

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

One tradition of ACM-ICPC contests is that a team gets a balloon for every solved problem. We assume that the submission time doesn't matter and teams are sorted only by the number of balloons they have. It means that one's place is equal to the number of teams with more balloons, increased by $1$ . For example, if there are seven teams with more balloons, you get the eight place. Ties are allowed.

You should know that it's important to eat before a contest. If the number of balloons of a team is greater than the weight of this team, the team starts to float in the air together with their workstation. They eventually touch the ceiling, what is strictly forbidden by the rules. The team is then disqualified and isn't considered in the standings.

A contest has just finished. There are $n$ teams, numbered $1$ through $n$ . The $i$ -th team has $t_{i}$ balloons and weight $w_{i}$ . It's guaranteed that $t_{i}$ doesn't exceed $w_{i}$ so nobody floats initially.

Limak is a member of the first team. He doesn't like cheating and he would never steal balloons from other teams. Instead, he can give his balloons away to other teams, possibly making them float. Limak can give away zero or more balloons of his team. Obviously, he can't give away more balloons than his team initially has.

What is the best place Limak can get?

输入格式

The first line of the standard input contains one integer $n$ ( $2<=n<=300000$ ) — the number of teams.

The $i$ -th of $n$ following lines contains two integers $t_{i}$ and $w_{i}$ ( $0<=t_{i}<=w_{i}<=10^{18}$ ) — respectively the number of balloons and the weight of the $i$ -th team. Limak is a member of the first team.

输出格式

Print one integer denoting the best place Limak can get.

输入输出样例

输入 #1
8
20 1000
32 37
40 1000
45 50
16 16
16 16
14 1000
2 1000
输出 #1
3
输入 #2
7
4 4
4 4
4 4
4 4
4 4
4 4
5 5
输出 #2
2
输入 #3
7
14000000003 1000000000000000000
81000000000 88000000000
5000000000 7000000000
15000000000 39000000000
46000000000 51000000000
0 1000000000
0 0
输出 #3
2
C++ 编辑器
输入
输出