Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help me with python USACO 2 0 2 3 December Contest, Silver Return to Problem List Problem 1 . Bovine ACrobatics Time Remaining: 3 h

Help me with python
USACO 2023 December Contest, Silver
Return to Problem List
Problem 1. Bovine ACrobatics
Time Remaining: 3hrs,59min,46sec
Not submitted yet
English (en)vv
Farmer John has decided to make his cows do some acrobatics! First, FJ weighs his cows and finds that they have N(1N2*105) distinct weights. In particular, for each iin[1,N],ai of his cows have a weight of )ai109,1wi(109.
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(109 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(109 balanced towers of cows, at most how many cows can be part of some tower?
INPUT FORMAT (pipe stdin):
The first line contains three space-separated integers, N,M, and K.
The next N lines contain two space-separated integers, wi and ai. It is guaranteed that all wi are distinct.
OUTPUT FORMAT (pipe stdout):
Output the maximum number of cows in balanced towers if FJ helps the cows form towers optimally.
SAMPLE INPUT:
3,52
9,4
7,6
5,5
SAMPLE OUTPUT:
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.
SAMPLE INPUT:
3,5
5,5
7,6
9,4
SAMPLE OUTPUT:
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.
SCORING:
In inputs 3-5,M5000 and the total number of cows does not exceed 5000.
In inputs 6-11, the total number of cows does not exceed 2*105.
Inputs 12-17 have no additional constraints.
Problem credits: Eric Hsu
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

LO6 Define harassment and the role that HR plays in addressing it.

Answered: 1 week ago