Usaco 2014 March silver

Source: Internet
Author: User
Usaco 2014 March

I. Question Overview

Chinese question name

Farmland Irrigation

Lainiu

Niuke

English question name

Irrigation

Lazy

Mooomoo

Executable File Name

Irrigation

Lazy

Mooomoo

Input File Name

Irrigation. In

Lazy. In

Mooomoo. In

Output file name

Irrigation. Out

Lazy. Out

Mooomoo. Out

Time limit for each test point

1 second

1 second

1 second

Number of test points

10

10

10

Score of each test point

10

10

10

Comparison Method

Full text comparison

Full text comparison

Full text comparison

Ii. Running memory limit

Maximum running memory

256 m

256 m

256 m

Note: Thank you for your translation. [Errors may occur, and the statements are not so fluent ......]

 

1.Farmland Irrigation{SilverQuestion1}

[Problem description]

John, a farmer, wants to build an irrigation system to deliver water to his n (1 <= n <= 2000) fields. On a two-dimensional plane, the coordinate of the I-th farmland is (XI, Yi) (0 <= xi, Yi <= 1000 ), the cost of self-built water pipes in farmland I and farmland J is the Euclidean distance (Xi-XJ) ^ 2 + (Yi-YJ) ^ 2 of these two farmland.

John, a farmer, wants all farmland to communicate with each other and spend the least money. However, the installer rejects the installation of water pipes (1 <= C <= 1,000,000) whose cost is less than C ).

Please help Farmer John build a irrigation network with the minimum cost.

[File input]

The first behavior is two integers, N and C.

Next 2. n + 1 rows, each line has two integers, representing XI, and Yi.

[File output]

The output is a row in total. An integer indicates the minimum cost. If no solution is available, the output is "-1 ".

[Example 1]

3 11

0 2

5 0

4 3

[Output Example 1]

46

 

 

2.Lainiu{SilverQuestion2}

[Problem description]

Bessie, a dairy cow, is very lazy. She wants to find the best place to live in her territory so that she can eat as much grass as possible in a limited number of steps.

Her website is a matrix of N rows and n columns (1 <= n <= 400). Column C of row R contains g (R, c) units of grass (0 <= g (R, c) <= 1000 ). From her place of residence, she is willing to take a maximum of K Steps (0 <= k <= 2 * n ), in each step, she can find a grid directly adjacent to top, bottom, left, and right.

For example, her place of residence is in B:

50

5

25 *

6

17

14

3 *

2 *

7 *

21

99 *

10 *

1 * (B)

2 *

80 *

8

7 *

5 *

23 *

11

10

0

78 *

1

9

When K = 2, she only wants to enter the position marked.

Please help her determine an optimal place to live, so that she can eat the most grass.

[File input]

In the first line, the two are separated by spaces in the integer N and K.

The matrix of n columns in the next n rows. Each number indicates the number of grass.

[File output]

An integer indicates the maximum amount of grass she can eat.

[Example 1]

5 2

50 5 25 6 17

14 3 2 7 21

99 10 1 2 80

8 7 5 23 11

10 0 78 1 9

[Output Example 1]

342

3.Niuke{SilverQuestion3}

[Problem description]

John, a farmer, forgot how many cows he had. He wanted to calculate the number of cows by collecting the volume of bits.

His n (1 <= n <= 100) farms are distributed in a straight line, and each farm may contain B (1 <= B <= 20) species of cattle, the volume of the ox of a breed I is V (I), (1 <= V (I) <= 100 ). A strong wind passes the call of the ox from left to right. If the total volume of a farm is X, it passes the volume of the X-1 to the next farm on the right. In addition, the total volume of a farm is equal to the volume produced by the farm's cattle plus the volume transferred from the previous farm (I .e. X-1 ). The total volume of any farm cannot exceed 100000.

Calculate the minimum possible number of cattle.

[File input]

In the first line, the two integers separated by spaces represent N and B respectively.

In row B, each row has an integer representing the volume of each ox.

In the next n rows, each row has an integer representing the total volume of the farm.

[File output]

A total of rows. An integer indicates the minimum number of cattle. If no solution is available,-1 is output.

[Example 1]

5 2

5

7

0

17

16

20

19

[Output Example 1]

4

[Example 1]

In farm 2, there are 2 cattle of breed 1 and 1 cattle of breed 2; in farm 4, there are 1 cattle of breed 1.

Usaco 2014 March silver

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.