Codeforces Round 351 (VK Cup 2016 Round 3, Div. 2 Edition)


A. Bear and Game
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
7 20 88
Output
35
Input
9
16 20 30 40 50 60 70 80 90
Output
15
Input
9
15 20 30 40 50 60 70 80 90
Output
90
----------------------------------------------------------------------------------------------------
B. Problems for Round
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
4
1 2 1 2
Output
7 3 0 0 
Input
3
1 1 1
Output
6 0 0 
----------------------------------------------------------------------------------------------------
D. Bear and Two Paths
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 11
2 4 7 3
Output
2 7 1 3 6 5 4
7 1 5 4 6 2 3
Input
1000 999
10 20 30 40
Output
-1
----------------------------------------------------------------------------------------------------
E. Levels and Regions
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
100 3 5 7
Output
5.7428571429
Input
6 2
1 2 4 8 16 32
Output
8.5000000000
----------------------------------------------------------------------------------------------------
F. Bearish Fanpages
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 12
10 20 30 40 50
2 3 4 5 2
2 1
2 2
2 3
2 4
2 5
1 4 2
2 1
2 2
2 3
2 4
2 5
3
Output
10
36
28
40
36
9
57
27
28
29
9 57
----------------------------------------------------------------------------------------------------
