Codeforces Round 890 (Div. 2) supported by Constructor Institute


A. Tales of a Sort
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
3
1 2 3
5
2 1 2 1 2
4
3 1 5 4
2
7 7
5
4 1 3 2 5
5
2 3 1 4 5
3
1000000000 1 2
Output
0
2
5
0
4
3
1000000000
----------------------------------------------------------------------------------------------------
B. Good Arrays
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
3
6 1 2
2
1 1
4
3 1 2 4
1
17
5
1 2 1 1 1
3
618343152 819343431 1000000000
Output
YES
NO
YES
NO
NO
YES
----------------------------------------------------------------------------------------------------
C. To Become Max
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
3 4
1 3 3
5 6
1 3 4 5 1
4 13
1 1 3 179
5 3
4 3 2 2 2
5 6
6 5 4 1 5
2 17
3 5
Output
4
7
179
5
7
6
----------------------------------------------------------------------------------------------------
D. More Wrong
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
4
1
0
2
1
Output
? 1 3
? 3 4
! 4
? 1 2
! 1
----------------------------------------------------------------------------------------------------
E1. PermuTree (easy version)
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
1 1 3 3
Output
4
Input
2
1
Output
0
Input
6
1 2 2 1 5
Output
7
Input
4
1 1 1
Output
2
----------------------------------------------------------------------------------------------------
E2. PermuTree (hard version)
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

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