Logo
(追記) (追記ここまで)

31060번 - Bovine Acrobatics 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB2931089846.226%

문제

Farmer John has decided to make his cows do some acrobatics! First, FJ weighs his cows and finds that they have $N$ (1ドル\le N\le 2\cdot 10^5$) distinct weights. In particular, for each $i\in [1,N],ドル $a_i$ of his cows have a weight of $w_i$ (1ドル\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 $K$ (1ドル\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 $M$ (1ドル \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, $N,ドル $M,ドル and $K$.

The next $N$ lines contain two space-separated integers, $w_{i}$ and $a_i$. It is guaranteed that all $w_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

FJ can create four balanced towers with cows of weights 5, 7, and 9, and one balanced tower with cows of weights 5 and 7.

예제 입력 2

3 5 3
5 5
7 6
9 4

예제 출력 2

9

FJ can create four balanced towers with cows of weights 5 and 9, and one balanced tower with a cow of weight 7. Alternatively, he can create four balanced towers with cows of weights 5 and 9, and one balanced tower with a cow of weight 5.

힌트

출처

Olympiad > USA Computing Olympiad > 2023-2024 Season > USACO 2023 December Contest > Silver 1번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /