Codeforces Round 518 (Div. 1) [Thanks, Mail.Ru!]


A. Array Without Local Maximums
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
1 -1 2
Output
1
Input
2
-1 -1
Output
200
----------------------------------------------------------------------------------------------------
B. Multihedgehog
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
14 2
1 4
2 4
3 4
4 13
10 5
11 5
12 5
14 5
5 13
6 7
8 6
13 6
9 6
Output
Yes
Input
3 1
1 3
2 3
Output
No
----------------------------------------------------------------------------------------------------
C. Knights
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
Output
1 1
3 1
1 5
4 4
Input
7
Output
2 1
1 2
4 1
5 2
2 6
5 7
6 6
----------------------------------------------------------------------------------------------------
D. Computer Game
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
3 1000 0.5
1 2 0.48
3 20 0.3
Output
252.2500000000000
Input
2 2
1 1000 0.1
2 3 0.2
Output
20.7200000000000
----------------------------------------------------------------------------------------------------
E. Random Forest Rank
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2
2 3
Output
6
Input
4
1 2
1 3
1 4
Output
14
Input
4
1 2
2 3
3 4
Output
18
----------------------------------------------------------------------------------------------------
