atcoder#ABC277H. [ABC277Ex] Constrained Sums
[ABC277Ex] Constrained Sums
Score : points
Problem Statement
Determine whether there is a sequence of integers that satisfies all of the following conditions, and construct one such sequence if it exists.
- for every .
- for every .
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
If there is an integer sequence that satisfies all of the conditions in the Problem Statement, print the elements of one such sequence, separated by spaces. Otherwise, print -1
.
4 5 3
1 3 5 7
1 4 1 2
2 2 3 8
2 4 3 0
For , we have , , and , so all conditions are satisfied. There are other sequences, such as and , that satisfy all conditions, and those will also be accepted.
3 7 3
1 2 3 4
3 1 9 12
2 3 2 4
-1
No sequence satisfies all conditions.