RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0582

Bovine Acrobatics

Gold I 골드 I
난이도
2s
시간 제한
256MB
메모리 제한
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 \(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?

Problem credits: Eric Hsu

제약

SCORING

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

Problem credits: Eric Hsu

입력 형식

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
출력
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
출력
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.

문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2023-2024 > December > Silver

태그

평가 및 의견

Bovine Acrobatics

개요
출제자 난이도 Gold I 골드 I 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Bovine Acrobatics

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8