아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Bovine Acrobatics

시간 제한2초메모리 제한1024 MB

요약
무게가 각각 다른 소들의 마릿수가 주어질 때, 위에 있는 소보다 무게가 K 이상 무거워야 하는 조건을 지키며 최대 M개의 탑을 만들어 포함되는 소의 최대 마릿수를 구한다.
난이도

보통10점 중 6점

유형
그리디, 정렬, 투 포인터, 시뮬레이션
정답자
아직 제출이 없습니다

문제

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], a_ia\_i of his cows have a weight of w_iw\_i (1≤a_i≤109,1≤w_i≤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, w_iw\_{i} and a_ia\_i. It is guaranteed that all w_iw\_i are distinct.

출력

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

예제2

  1. 예제 1

    입력
    3 5 2
    9 4
    7 6
    5 5
    
    예상 출력
    14
    
  2. 예제 2

    입력
    3 5 3
    5 5
    7 6
    9 4
    
    예상 출력
    9