Codeforces Round 700 (Div. 1)


A. Searching Local Minimum
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
3
2
1
4
5
Output
? 1
? 2
? 3
? 4
? 5
! 3
----------------------------------------------------------------------------------------------------
B1. Painting the Array I
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
7
1 1 2 2 3 3 3
Output
6
Input
7
1 2 3 4 5 6 7
Output
7
----------------------------------------------------------------------------------------------------
B2. Painting the Array II
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
6
1 2 3 1 2 2
Output
4
Input
7
1 2 1 2 1 2 1
Output
2
----------------------------------------------------------------------------------------------------
C. Continuous City
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
1 1
Output
YES
2 1
1 2 1
Input
4 6
Output
YES
5 6
1 2 3
1 3 4
1 4 5
2 5 1
3 5 1
4 5 1
----------------------------------------------------------------------------------------------------
D. Odd Mineral Resource
time limit per test: 5 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
6 8
3 2 1 3 1 3
1 2
1 3
2 4
2 5
4 6
3 5 1 1
3 5 1 3
3 5 1 3
1 1 2 2
1 1 3 3
1 4 1 5
1 6 1 3
1 6 1 3
Output
-1
2
3
-1
3
2
2
3
----------------------------------------------------------------------------------------------------
E. School Clubs
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
1 1
Output
4
Input
2
1 2
Output
18
Input
3
1 1 1
Output
21
Input
1
400000000
Output
0
Input
10
1 2 3 4 5 6 7 8 9 10
Output
737609878
----------------------------------------------------------------------------------------------------
