Codeforces Round 772 (Div. 2)


A. Min Or Sum
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3
1 3 2
5
1 2 4 8 16
2
6 6
3
3 5 6
Output
3
31
6
7
----------------------------------------------------------------------------------------------------
B. Avoid Local Maximums
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3
2 1 2
4
1 2 3 1
5
1 2 1 2 1
9
1 2 1 3 2 3 1 2 1
9
2 1 3 1 3 1 3 1 3
Output
0
2 1 2
1
1 3 3 1
1
1 2 2 2 1
2
1 2 3 3 2 3 3 2 1
2
2 1 3 3 3 1 1 1 3
----------------------------------------------------------------------------------------------------
C. Differential Sorting
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
2 4
6 1
Output
9
Input
4 7
20 39 5 200
Output
14
Input
2 200000
48763 1000000000
Output
448201910
----------------------------------------------------------------------------------------------------
E. Cars
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4 4
1 1 2
1 2 3
2 3 4
2 4 1
Output
YES
R 0
L -3
R 5
L 6
Input
3 3
1 1 2
1 2 3
1 1 3
Output
NO
----------------------------------------------------------------------------------------------------
F. Closest Pair
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 5
-2 2
0 10
1 1
9 2
12 7
1 3
2 3
1 5
3 5
2 4
Output
9
11
9
24
11
----------------------------------------------------------------------------------------------------
