Huawei OD Machine Test Real Questions-Robot Warehouse Moving Bricks-2023 OD Unified Examination (Paper C)

Topic description:

The robot moves bricks. There are a total of N piles of bricks stored in N different warehouses. There are bricks[i] bricks in the i-th pile of bricks, and they are required to be moved within 8 hours. The number of bricks the robot can move per hour depends on how many energy grids it has. The robot can only move bricks in one warehouse in an hour. The robot's energy grid is replenished once an hour and the energy grid is only valid during this hour. In order to make the robot lose Minimize as much as possible to reduce the number of energy grids replenished each time.

In order to ensure that the brick-moving task can be completed within 8 hours, please calculate the minimum number of energy grids required to charge the robot per hour.

Remark:

1. There is no need to consider the time it takes for the robot to replenish its energy grid;

2. There is no need to consider the time it takes for robots to move bricks;

3. The robot's hourly replenishment of energy grids is only valid during this hour;

Enter description:

The program input is an integer array "30 12 25 8 19". Each number in the array represents the number of bricks in the i-th pile, and the number of bricks in each pile does not exceed 100.

Output description:

The output is to complete the task of moving bricks within 8 hours. How many energy bars does the robot need to charge per hour?

If the task cannot be completed within 8 hours anyway, "-1" will be output;

Additional notes:

Example 1

enter:

30 12 25 8 19

Output:

15

illustrate:

Example 2

enter:

10 12 25 8 19 8 6 4 17 19 20 30

Output:

-1

illustrate:

There are 12 piles of bricks stored in 12 warehouses. The robot can only move bricks in one warehouse in an hour.

Supongo que te gusta

Origin blog.csdn.net/2301_76848549/article/details/135424934
Recomendado
Clasificación