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 from each of them. Given an array, is it possible to make all values equal to 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 ), then decrement the last two values twice (yielding ), and finally decrement the entire array once (yielding ).
Giriş formatı
The input consists of:
• One line with an integer (), the length of the array.
• One line with integers (), the values in the array.
Çıxış formatı
If it is possible to make all values of the array equal to 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