#645
Unrated

Bovine Acrobatics

시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Farmer John has decided to make his cows do some acrobatics! First, FJ weighs his cows and finds that they have NN (1≤N≤2⋅1051\le N\le 2\cdot 10^5) distinct weights. In particular, for each i∈[1,N]i\in [1,N], aia_i of his cows have a weight of wiw_i (1≤ai≤109,1≤wi≤1091\le a_i\le 10^9, 1\le w_i\le 10^9).

His most popular stunt involves the cows forming balanced towers. A tower is a sequence of cows where each cow is stacked on top of the next. A tower is balanced if every cow with a cow directly above it has weight at least KK (1≤K≤1091\le K\le 10^9) greater than the weight of the cow directly above it. Any cow can be part of at most one balanced tower.

If FJ wants to create at most MM (1≤M≤1091 \le M \le 10^9) balanced towers of cows, at most how many cows can be part of some tower?

입력

The first line contains three space-separated integers, NN, MM, and KK.

The next NN lines contain two space-separated integers, wiw_{i} and aia_i. It is guaranteed that all wiw_i are distinct.

출력

Output the maximum number of cows in balanced towers if FJ helps the cows form towers optimally.

예제 입력 1

3 5 2
9 4
7 6
5 5

예제 출력 1

14

예제 입력 2

3 5 3
5 5
7 6
9 4

예제 출력 2

9

점수

In inputs 3-5, M≤5000M \leq 5000 and the total number of cows does not exceed 50005000.In inputs 6-11, the total number of cows does not exceed 2⋅1052\cdot 10^5.Inputs 12-17 have no additional constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출

제출 내역이 없습니다.

맞은 사람

아직 맞은 사람이 없습니다.

난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출

제출 내역이 없습니다.