Bovine Acrobatics
시간 제한2초메모리 제한1024 MB
무게가 각각 다른 소들의 마릿수가 주어질 때, 위에 있는 소보다 무게가 K 이상 무거워야 하는 조건을 지키며 최대 M개의 탑을 만들어 포함되는 소의 최대 마릿수를 구한다.
문제
Farmer John has decided to make his cows do some acrobatics! First, FJ weighs his cows and finds that they have () distinct weights. In particular, for each , of his cows have a weight of ().
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 () 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 () balanced towers of cows, at most how many cows can be part of some tower?
입력
The first line contains three space-separated integers, , , and .
The next lines contain two space-separated integers, and . It is guaranteed that all are distinct.
출력
Output the maximum number of cows in balanced towers if FJ helps the cows form towers optimally.