101873: [AtCoder]ABC187 D - Choose Me

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $400$ points

Problem Statement

AtCoder City will hold a mayoral election. The candidates are Aoki and Takahashi.
The city consists of $N$ towns, the $i$-th of which has $A_i$ pro-Aoki voters and $B_i$ pro-Takahashi voters. There are no other voters.
Takahashi can make a speech in each town.
If he makes a speech in some town, all voters in that town, pro-Takahashi or pro-Aoki, will vote for Takahashi.
On the other hand, if he does not make a speech in some town, the pro-Aoki voters in that town will vote for Aoki, and the pro-Takahashi voters will not vote.
To get more votes than Aoki, in how many towns does Takahashi need to make speeches at least?

Constraints

  • All values in input are integers.
  • $1 \le N \le 2 \times 10^5$
  • $1 \le A_i, B_i \le 10^9$

Input

Input is given from Standard Input in the following format:

$N$
$A_1$ $B_1$
$\vdots$
$A_N$ $B_N$

Output

Print the answer.


Sample Input 1

4
2 1
2 2
5 1
1 3

Sample Output 1

1

After making a speech in the third town, Aoki and Takahashi will get $5$ and $6$ votes, respectively.


Sample Input 2

5
2 1
2 1
2 1
2 1
2 1

Sample Output 2

3

After making speeches in three towns, Aoki and Takahashi will get $4$ and $9$ votes, respectively.


Sample Input 3

1
273 691

Sample Output 3

1

Input

题意翻译

### 题目简述 农场一年一度的选农场主开始啦! 选举的人有 Farmer John 和 Farmer Jack,全农场有 $N$ 个片区,第 $i$ 个片区有 $a_i$ 只 Jack 的奶牛,$b_i$ 只 John 的奶牛,没有其他人的奶牛。 John 要在各个片区发放牧草。 如果 John 在一个区发放牧草,那么所有 John 和 Jack 的奶牛都会投票支持 John,另一方面,如果 John 不在该区发放牧草,所有 Jack 的奶牛投票支持 Jack ,而 John 的奶牛不参与投票。 求John 想赢得比 Jack 多的选票,至少要去发放牧草的片区数量 $X$ 。 ### 输入格式 第一行是一个整数 $N$, 第 $2$ 到第 $N+1$ 行,分别是两个整数 $a_i, b_i$ 。 ### 输出格式 一个所求的整数 $X$ 。

加入题单

算法标签: