Codeforces Round 800 (Div. 1)


A. Directional Increase
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
2
1 0
4
2 -1 -1 0
4
1 -4 3 0
4
1 -1 1 -1
5
1 2 3 4 -10
7
2 -1 1 -2 0 0 0
1
0
Output
No
Yes
No
No
Yes
Yes
Yes
----------------------------------------------------------------------------------------------------
B. Fake Plastic Trees
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2
1
1 5
2 9
3
1 1
4 5
2 4
6 10
4
1 2 1
6 9
5 6
4 5
2 4
5
1 2 3 4
5 5
4 4
3 3
2 2
1 1
Output
1
2
2
5
----------------------------------------------------------------------------------------------------
C. Keshi in Search of AmShZ
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 1
1 2
Output
1
Input
4 4
1 2
1 4
2 4
1 4
Output
2
Input
5 7
1 2
2 3
3 5
1 4
4 3
4 5
3 1
Output
4
----------------------------------------------------------------------------------------------------
D. Decinc Dividing
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 3 1
Output
6
Input
6
4 5 2 6 1 3
Output
19
Input
10
7 10 1 8 3 9 2 4 6 5
Output
39
----------------------------------------------------------------------------------------------------
E. Outermost Maximums
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
1 4 2 4 0 2
Output
7
Input
5
1 3 5 4 2
Output
9
Input
4
0 0 0 0
Output
0
----------------------------------------------------------------------------------------------------
F. I Might Be Wrong
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
1
1
2
10
3
101
4
1000
5
11010
6
110000
20
01000010001010011000
Output
0
1
1
3
2
2
5
----------------------------------------------------------------------------------------------------
