AlgoLensArena
ContestlərProblemlərOtaqlar
Vizualizator
← Məsələlər

FPC25-004.Array Annihilation

Easy · 2 s · 256 MB

  • icpc
  • fpc
  • 2025

Already another algorithms assignment about arrays – Amy has absolute aversion to them all! To avenge the amountful assignments, she activates an Array Annihilator Pledging Justice Executable, so all annoying arrays are abolished.

As the arrays are astronomically large, she agrees to only use one type of operation repeatedly. For each operation, she chooses two or more consecutive values in the array, and subtracts 111 from each of them. Given an array, is it possible to make all values equal to 000 in some finite number of these operations?

As an example, consider the second sample input. The array can be fully annihilated in four operations: first, decrement the first two values (yielding [1,3,3][1,3,3][1,3,3]), then decrement the last two values twice (yielding [1,1,1][1,1,1][1,1,1]), and finally decrement the entire array once (yielding [0,0,0][0,0,0][0,0,0]).

Giriş formatı

The input consists of:

• One line with an integer nnn (1≤n≤5⋅1051 \le n \le 5\cdot 10^51≤n≤5⋅105), the length of the array.

• One line with nnn integers aaa (1≤a≤1091 \le a \le 10^91≤a≤109), the values in the array.

Çıxış formatı

If it is possible to make all values of the array equal to 000 in some finite number of operations, output “possible”. If this is not possible, output “impossible”.

Qeyd

Source: Freshmen Programming Contest 2025 · License: CC BY-SA 4.0 · Original: https://fpc.wisv.ch · Statement adapted for AlgoLens and shared under the same license. · 2 of the 26 original test cases (the largest) are omitted here to keep the problem lightweight.

Nümunələr

Giriş #1

2
1 1

Çıxış #1

possible

Giriş #2

3
2 4 3

Çıxış #2

possible

Giriş #3

1
5

Çıxış #3

impossible

Giriş #4

4
2 1 1 2

Çıxış #4

impossible

Giriş #5

9
3 4 5 5 1 2 3 2 1

Çıxış #5

possible