Codeforces Round 353 (Div. 2)


A. Infinite Sequence
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 7 3
Output
YES
Input
10 10 0
Output
YES
Input
1 -4 5
Output
NO
Input
0 60 50
Output
NO
----------------------------------------------------------------------------------------------------
B. Restoring Painting
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 1 1 1 2
Output
2
Input
3 3 1 2 3
Output
6
----------------------------------------------------------------------------------------------------
C. Money Transfers
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
5 0 -5
Output
1
Input
4
-1 0 1 0
Output
2
Input
4
1 2 3 -6
Output
3
----------------------------------------------------------------------------------------------------
D. Tree Construction
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 3
Output
1 2
Input
5
4 2 3 1 6
Output
4 2 2 4
----------------------------------------------------------------------------------------------------
E. Trains and Statistic
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4 4 4
Output
6
Input
5
2 3 5 5
Output
17
----------------------------------------------------------------------------------------------------
