Olympiad Maths Prep

Track / Stage 7 / 146 of 300 #1546 of 2000

Problem 1546

National olympiad second round; IMO P1/P4
Combinatorics Difficulty 7.3 Find the answer

Given nn numbers different from 00, (nNn \in \mathbb{N}) which are arranged randomly. We do the following operation: Choose some consecutive numbers in the given order and change their sign (i.e. xxx \rightarrow -x). What is the minimum number of operations needed, in order to make all the numbers positive for any given initial configuration of the nn numbers?

Official solution

Given n n numbers different from 0 0 , which are arranged randomly. We need to determine the minimum number of operations needed to make all the numbers positive. The operation allowed is to choose some consecutive numbers in the given order and change their sign (i.e., xx x \rightarrow -x ).

1. Define a 'block':
A 'block' is a series of consecutive numbers with the same sign. For example, in the sequence +++++ +++---++ , there are three blocks: +++ +++ , --- , and ++ ++ .

2. First Assertion:
To minimize the number of operations, we should always change the sign of all members of a block in one operation. If we do not do this, the number of blocks will either stay the same or increase.

Proof:
Consider two consecutive blocks, such as ...+++++++++++... ...+---------++++++++++-... . If we do not change the entire block, we might end up with a situation like ...++++++++++++++++... ...+---+++++++++++++++-... (the number of blocks stays the same) or ...++++++++++++... ...+------+++++------++++++-... (the number of blocks increases). Therefore, to reduce the number of blocks, we must change the entire block at once.

3. Second Assertion:
Let B B be the number of distinct blocks. It is always possible to decrease B B by 2 during one operation, and it is not possible to decrease B B by more than 2 during one operation.

Proof:
Consider the blocks as (+) (+) and () (-) . If B>2 B > 2 , there exists a situation like (+)()(+) (+)(-)(+) (or with the signs inverted). If B=2 B = 2 , we are almost finished. By changing the block () (-) , we arrive at (+)(+)(+) (+)(+)(+) , and B B decreases by 2. Changing several blocks at once does not decrease B B by more than 2 because the borders between the blocks within the series stay the same, and only the edges might merge with outside blocks, reducing B B by at most 2.

4. Minimizing the Number of Operations:
We want to reach B=1 B = 1 in the fewest moves possible. We will only change whole blocks at a time. Changing a block on the edge decreases B B by only 1 at a time.

5. Maximal Number of Blocks:
Consider the situation where the number of blocks is maximal, B=n B = n . This means each number is a separate block.

- **Case 1: n n is even:**
The sequence is ++...+ +-+-...+- with n/2 n/2 blocks (+) (+) and n/2 n/2 blocks () (-) . In n/21 n/2 - 1 moves, B B will be equal to 2. Therefore, the minimum number of moves needed is n/2 n/2 .

- **Case 2: n n is odd:**
Using the same arguments, it will take n/2 \lfloor n/2 \rfloor moves to get to B=1 B = 1 . However, we need all numbers to be positive. If the initial position has minuses on the edges, after n/2 \lfloor n/2 \rfloor moves, all signs will be negative. We need one additional move to make all numbers positive. Therefore, the minimum number of moves needed is n/2+1 \lfloor n/2 \rfloor + 1 .

The final answer is n2+1 \boxed{\left\lfloor \frac{n}{2} \right\rfloor + 1} if n n is odd, and n2 \boxed{\frac{n}{2}} if n n is even.

Source: NuminaMath-1.5, licensed Apache-2.0. Statement and solution reproduced as published; topic, difficulty and ordering added by this site.