Codeforces Round 840 (Div. 2) and Enigma 2022 - Cybros LNMIIT


A. Absolute Maximization
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3
1 0 1
4
5 5 5 5
5
1 2 3 4 5
7
20 85 100 41 76 49 36
Output
1
0
7
125
----------------------------------------------------------------------------------------------------
B. Incinerate
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
6 7
18 5 13 9 10 1
2 7 2 1 2 6
3 4
5 5 5
4 4 4
3 2
2 1 3
1 1 1
Output
YES
NO
YES
----------------------------------------------------------------------------------------------------
C. Another Array Problem
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3
1 1 1
2
9 1
3
4 9 5
Output
3
16
18
----------------------------------------------------------------------------------------------------
D. Valid Bitonic Permutations
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
3 1 3 2 3
3 2 3 3 2
4 3 4 3 1
5 2 5 2 4
5 3 4 5 4
9 3 7 8 6
20 6 15 8 17
Output
0
1
1
1
3
0
4788
----------------------------------------------------------------------------------------------------
E. Node Pairs
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
Output
3 0
Input
4
Output
5 6
Input
0
Output
0 0
----------------------------------------------------------------------------------------------------
F. Edge Queries
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 11
1 2
2 3
3 4
4 5
5 3
2 7
7 9
9 10
10 6
6 7
1 8
5
1 4
5 10
3 5
2 8
7 10
Output
3
7
3
0
4
Input
13 15
1 2
2 3
3 4
4 1
2 4
3 5
5 6
6 7
6 8
7 9
9 10
8 7
10 11
10 12
10 13
6
9 11
1 5
1 8
5 2
5 12
12 13
Output
0
5
8
5
3
0
----------------------------------------------------------------------------------------------------
