Codeforces Round 768 (Div. 2)


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

Examples
Input
3
6
1 2 6 5 1 2
3 4 3 2 2 5
3
3 3 3
3 3 3
2
1 2
2 1
Output
18
9
2
----------------------------------------------------------------------------------------------------
B. Fun with Even Subarrays
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3
1 1 1
2
2 1
5
4 4 4 2 4
4
4 2 1 3
1
1
Output
0
1
1
2
0
----------------------------------------------------------------------------------------------------
C. And Matching
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4 0
4 1
4 2
4 3
Output
0 3
1 2
0 2
1 3
0 1
2 3
-1
----------------------------------------------------------------------------------------------------
D. Range and Partition
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 1
1 2
4 2
1 2 2 2
11 3
5 5 5 1 5 5 1 5 5 5 1
Output
1 2
1 2
2 2
1 3
4 4
5 5
1 1
2 2
3 11
----------------------------------------------------------------------------------------------------
E. Paint the Middle
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
1 2 1 2 7 4 7
Output
2
Input
13
1 2 3 2 1 3 3 4 5 5 5 4 7
Output
7
----------------------------------------------------------------------------------------------------
F. Flipping Range
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
6 2
0 6 -2 1 -4 5
1 2
7 1
1 -1 1 -1 1 -1 1
2
5 1
-1000000000 -1000000000 -1000000000 -1000000000 -1000000000
1
Output
18
5
5000000000
----------------------------------------------------------------------------------------------------
