Блог пользователя Von.

Автор Von., 13 месяцев назад, По-английски

Hello everyone,

I recently came across an interesting problem, and I'm trying to find its original problem ID on Codeforces. Here’s the problem description:

Problem Statement:

In a future super data center, servers are installed on multiple racks. Each rack contains several servers, arranged from bottom to top. The servers in each rack are randomly distributed, but every rack has at least one server.

To ensure proper operation, a maintenance robot needs to inspect all servers using the following two modes:

  1. Row inspection: The robot can check multiple rows of servers at the same time across different racks, taking 1 second per inspection.
  2. Column inspection: The robot can check servers in a single column, taking 2 seconds per inspection.

Constraints:

  • The robot can check the same server multiple times, but each row or column inspection must be continuous.
  • If a server is inspected separately, column inspection is used by default, taking 2 seconds.
  • The inspection time depends only on the method used, not the number of servers covered.

Input Format:

  • The first line contains an integer n, representing the number of racks.
  • The second line contains n integers, where each integer represents the number of servers in a respective rack.

Output Format:

Output a single integer, the minimum time (in seconds) required to inspect the entire data center.

Example:

Input 1:

3  
5 5 5  

Output 1:

1  

Explanation 1:

Since all racks have the same number of servers, one row check covers all servers, taking 1 second.

Input 2:

5  
2 2 1 2 1  

Output 2:

4  

Explanation 2:

  1. First row check covers the first row of all servers in 1 second.
  2. Second row check covers the second row of servers in columns 1 and 2 in 1 second.
  3. Third column check covers the second-row server in column 4 in 2 seconds.
  4. Total time: 4 seconds.

Input 3:

5
7 4 3 3 5

Output 3:

6

Explanation 3:

  1. First row check: Covers 1~3 rows of servers in columns 1~5, taking 1 second.
  2. Second row check: Covers 4th row of servers in columns 1~2, taking 1 second.
  3. Third column check: Checks 5~7 rows of servers in column 1, taking 2 seconds.
  4. Fourth column check: Checks 4~5 rows of servers in column 5, taking 2 seconds.
  5. Total time: 1 + 1 + 2 + 2 = 6 seconds.

28.png

I suspect this problem might already exist on Codeforces, but I couldn’t find the exact problem ID. If anyone recognizes it or knows where it might be from, please let me know. Thanks in advance!

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится