Codeforces Round 783 (Div. 2)


A. Direction Change
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
1 1
2 1
1 3
4 2
4 6
10 5
Output
0
1
-1
6
10
17
----------------------------------------------------------------------------------------------------
B. Social Distance
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
3 2
1 1 1
2 4
1 1
2 5
2 1
3 8
1 2 1
4 12
1 2 1 3
4 19
1 2 1 3
Output
NO
YES
NO
YES
NO
YES
----------------------------------------------------------------------------------------------------
C. Make it Increasing
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 3 4 5
Output
4
Input
7
1 2 1 2 1 2 1
Output
10
Input
8
1 8 2 7 3 6 4 5
Output
16
----------------------------------------------------------------------------------------------------
D. Optimal Partition
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3
1 2 -3
4
0 -2 3 -4
5
-1 -2 3 -1 -1
6
-1 2 -3 4 -5 6
7
1 -1 -1 1 -1 -1 1
Output
1
2
1
6
-1
----------------------------------------------------------------------------------------------------
E. Half Queen Cover
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
Output
1
1 1
Input
2
Output
1
1 1
Input
3
Output
2
1 1
1 2
----------------------------------------------------------------------------------------------------
F. Edge Elimination
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2
1 2
3
1 2
2 3
4
1 2
2 3
3 4
5
1 2
2 3
3 4
3 5
7
1 2
1 3
2 4
2 5
3 6
3 7
Output
YES
2 1
NO
YES
2 3
3 4
2 1
YES
3 5
2 3
2 1
4 3
NO
----------------------------------------------------------------------------------------------------
