USACO translation: USACO 2014 DEC Silver Three Questions

USACO 2014 DEC SILVER

I, entitled Overview

Chinese title name

Return trip

marathon

Cows jogging

English title name

piggyback

marathon

cowjog

Executable file name

piggyback

marathon

cowjog

Enter the file name

piggyback.in

marathon.in

cowjog.in

Output filename

piggyback.out

marathon.out

cowjog.out

Each test point of time limit

1 second

1 second

1 second

The number of test points

10

10

10

Each test point score

10

10

10

Compare the way

Compare the full text

Compare the full text

Compare the full text

Second, run the memory limit

Run memory limit

128 M

128 M

128 M

 

1. Return {piggyback}

【Problem Description】

Bessie and Elsie grazing in different areas, they want to spend a minimum of energy returned barn. A region connected to the energy went, Bessie takes B units from a region, Elsie takes energy E units.

If a second region both of them come to the same, carrying Elsie Bessie can walk, energy cost per unit of P region went further connected to a satisfied P <B + E.

After the encounter, they may have been carrying away, it can also be separately and independently.

[File Input]

   The first line, a positive integer of not more than five of the B 40,000, E, P, N and M. Where N represents the number of regions (region number 1..N respectively, N> = 3), M represents the number of two-way connection between the side edges of the respective regions. Bessie beginning in the region of 1, Elsie in region 2, in the region of the barn N.

   Next M rows, each row represents an integer of two sides of a bidirectional connecting the two regions, to ensure that the input can go to region 1 and region 2 N. region

[File Output]

   Line, an integer, the smallest unit of energy spent.

[Sample input]

4 4 5 8 8

1 4

2 3

3 4

4 7

2 5

5 6

6 8

7 8

[Sample Output]

22

[Sample Description]

Bessie from 1 to 4 Elsie from 2 to 3 to 4, and then with from 4 to 7 to 8.

2. Marathon {marathon}

【Problem Description】

Bessie participate City Marathon, to sequence through the N (3 <= N <= 500) checkpoint, the checkpoint where 1 is the starting point, the end point is N checkpoint. Bessie skip attempt K (K <N) checkpoint, in order to reduce the total distance, a checkpoint Checkpoints and N can not be ignored. Distance between two checkpoints is | x1-x2 | + | y1-y2 |.

[File Input]

   Line, two integers N and K.

Next N lines of two integers X and Y, (- 1000 <= x <= 1000, -1000 <= y <= 1000), N represents the coordinates of the checkpoints, the checkpoint is the N sequence is given, it must be through sequence. Note that there may be multiple occurrences of the same checkpoint, when a particular Bessie skip the checkpoint, he can skip the current one, but not both skip all occurrences of the checkpoint.

[File Output]

   Line, an integer representing the total distance Bessie passed.

[Sample input]

5 2

0 0

8 3

1 1

10 -5

2 2

[Sample Output]

4

[Sample Description]

Skip check point (8, 3) and (10, -5).

3. Cow jogging { cowjog}

【Problem Description】

There are N (1 <= N <= 100,000) in cows jogging of a single long track, the start position of each cow is different. Because it is single track, all of them can not go beyond each other. When a faster speed to catch up with another cow a cow, he must drop the same speed crash. We ran away and these cattle the same speed as a group the same location.

Calculate T (1 <= T <= 1,000,000,000) time, how many cows will be divided into teams.

[File Input]

The first line, two integers N and T.

Next N lines of two numbers, respectively, every cow initial velocity and initial position P S. Where (0 <= P <= 1000,000,000), (1 <= S <= 1000,000,000). Input data in ascending order given in the initial position.

[File Output]

Line, an integer that represents the number of teams.

[Sample input]

5 3

0 1

1 2

2 3

3 2

6 1

[Sample Output]

3

Reproduced in: https: //www.cnblogs.com/jznoi/p/4280805.html

Guess you like

Origin blog.csdn.net/weixin_34240657/article/details/93452776