11th Week Practice

Source: Internet
Author: User

1. Rectangular Split

Total time limit: 1000ms memory limit: 65536kB

Describe:

There is a large rectangle on the plane, its lower-left coordinate (0,0), and the upper-right coordinate (r,r). The interior of the large rectangle contains small rectangles, which are parallel to the axes and do not overlap. The vertices of all rectangles are the whole point. A line X=k (k is an integer) parallel to the Y axis is required, so that the area to the left of these small rectangles must be greater than or equal to the area on the right, with the smallest difference between the sides. Also, make the large rectangular area as large as possible on the left side of the line. Note: If a straight line passes through a small rectangle, it will be cut into two parts, which belong to the left and right sides.

Input:

The first line is an integer R, which indicates that the upper-right coordinate of the large rectangle is (r,r) (1 <= R <= 1,000,000).
The next line is the integer n, which indicates a total of n small rectangles (0 < N <= 10000).
Then there are n rows. Each line has 4 integers, l,t, W, and H, indicating that the upper-left coordinate of a small rectangle is (l,t), the width is W, and the height is H (0<=l,t <= R)

Output:

Output integer n, indicating that the answer should be a straight line x=n. If necessary, x=r can also be the answer.

Sample input:

 + 2 1 1 2 1 5 1 2 1

Sample output:

5  

Code:

2. Send

Total time limit: 1000ms memory limit: 65536kB

Describe:

My birthday is coming! According to custom, I need to share some of the pies. I have n different tastes, different sizes of pies. f A friend will come to my party, everyone will get a piece of pie (must a piece of pie, not by a few pies of small pieces, can be a whole pie).

My friends are especially stingy, and if someone gets a bigger piece, they start complaining. So everyone gets a pie of the same size (but doesn't need to be the same shape), though some will be wasted, but it's better than screwing the whole party. Of course, I also want to give myself a piece, and this piece will be the same size as other people.

What is the maximum number of pies each of us get? Each faction is a cylinder with a height of 1 and a range of radii.

Input:

The first line contains two positive integers N and f,1≤n, F≤10 000, representing the number of pies and the number of friends.
The second line contains an integer of n 1 to 10000, representing the radius of each pie.

Output:

Output the maximum pie size that everyone can get, accurate to three digits after the decimal point.

Sample input:

3 3 4 3 3

Sample output:

Code:

3. Monthly expenses

Total time limit: 1000ms memory limit: 65536kB

Describe:

The farmer John is a shrewd accountant. He realized that he might not have enough money to keep the farm running. He calculates and records the overhead required for the next n (1≤ n ≤100,000) day.

John intends to create a budget for the successive m (1≤ mN) fiscal cycle, which he named a fiscal period of fajo months. Each Fajo month consists of one or more consecutive days, each day being contained in a Fajo month.

John's goal is to rationalize the number of days that each Fajo month contains, making the cost of the most expensive Fajo month as low as possible.

Input:

The first line contains two integer n,m separated by a single space.
Next n rows, each line contains an integer between 1 and 10000, giving the cost per day for the next N days in order.

Output:

An integer that is the minimum value for the maximum monthly cost.

Sample input:

7 5  -  -  -  -  - 101  -

Sample output:

Tips:

Joyo the first two days as one months, the third to fourth two days as one months, the last three days as one months, the maximum monthly cost is 500. Any other allocation will be larger than this.

Code:

4. Jumping House in the river

Total time limit: 1000ms memory limit: 65536kB

Describe:

Every year, the cows have a special version of the Jumping House competition, including jumping from one rock to another in the river. This exciting activity is carried out in a long, straight channel with a rock at the end of the starting point and the far from the beginning L (1≤ l≤1,000,000,000). Between the starting point and the end point, there are n (0≤ n ≤50,000) rocks, each rock with a starting distance of di (0 < di < L) respectively.

During the race, the cows take turns starting from the beginning, trying to reach the finish line, and each step can only jump from one rock to another rock. Of course, the weak cows have no way of accomplishing their goals.

Farmer John was proud of his cows and watched the game every year. But as time went by, he was bored to watch the other farmer's timid cows move slowly between the rocks that were very close. He plans to remove some rocks so that the shortest jumping distance from the starting point to the end point is the longest. He can remove up to m (0≤ mN) rocks except the starting and ending points.

Please help John to determine the maximum possible minimum jumping distance after removing these rocks.

Input:

The first line consists of three integer l, N, M, and two adjacent integers separated by a single space.
The next n rows, an integer per line, represent the distance between each rock and the starting point. The rock is given from near to far, and no two rocks appear in the same position.

Output:

An integer that is the longest possible shortest jump distance.

Sample input:

 - 5 2 2  One  -  -  +

Sample output:

Tips:

After removing two rocks at 2 and 14, the shortest jump distance is 4 (from 17 to 21 or from 21 to 25).

Code:

5.Aggressive cows

Total time limit: 1000ms memory limit: 65536kB

Describe:

Farmer John had built a new long barn, with N (2 <= n <= 100,000) stalls. The stalls is located along a straight line at positions X1,..., XN (0 <= XI <= 1,000,000,000).

His C (2 <= C <= N) cows don ' t like this barn layout and become aggressive towards each other once put into a stall. To prevent the cows from hurting all other, FJ want to assign the cows to the stalls, such that the minimum distance bet Ween any and them is as large as possible. What's the largest minimum distance?

Input:

* Line 1:two space-separated integers:n and C

* Lines 2..n+1:line i+1 contains an integer stall location, xi

Output:

* Line 1:one integer:the largest minimum distance

Sample input:

5 3 1 2 8 4 9

Sample output:

Tips:

OUTPUT DETAILS:

FJ can put his 3 cows in the stalls at positions 1, 4 and 8, resulting in a minimum distance of 3.

Huge input data,scanf is recommended.

Code:

11th Week Practice

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.