Codeforces Round 428 (Div. 2)


A. Arya and Bran
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 3
1 2
Output
2
Input
3 17
10 10 10
Output
3
Input
1 9
10
Output
-1
----------------------------------------------------------------------------------------------------
B. Game of the Rows
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2
5 8
Output
YES
Input
1 2
7 1
Output
NO
Input
1 2
4 4
Output
YES
Input
1 4
2 2 1 2
Output
YES
----------------------------------------------------------------------------------------------------
C. Journey
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 2
1 3
2 4
Output
1.500000000000000
Input
5
1 2
1 3
3 4
2 5
Output
2.000000000000000
----------------------------------------------------------------------------------------------------
D. Winter is here
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 3 1
Output
12
Input
4
2 3 4 6
Output
39
----------------------------------------------------------------------------------------------------
E. Mother of Dragons
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 1
0 1 0
1 0 0
0 0 0
Output
0.250000000000
Input
4 4
0 1 0 1
1 0 1 0
0 1 0 1
1 0 1 0
Output
4.000000000000
----------------------------------------------------------------------------------------------------
