VK Cup 2016 - Round 1


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

Examples
Input
4 2 8
300 950 500 200
1 3
2 4
2 3
1 1
1 2
2 1
2 2
2 3
Output
NO
YES
NO
YES
YES
Input
6 3 9
50 20 51 17 99 24
1 3
1 4
1 5
1 2
2 4
2 2
1 1
2 4
2 3
Output
NO
YES
NO
YES
----------------------------------------------------------------------------------------------------
B. Bear and Forgotten Tree 3
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
3 1000000000
10 -9 -3 5
Output
3
Input
3 12
10 -9 -3 5
Output
2
Input
2 20
14 -7 19
Output
0
----------------------------------------------------------------------------------------------------
D. Bear and Contribution
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3 100 30
12 2 6 1
Output
220
Input
4 3 30 100
12 2 6 1
Output
190
Input
6 2 987 789
-8 42 -4 -65 -8 -8
Output
0
----------------------------------------------------------------------------------------------------
E. Bear and Paradox
time limit per test: 3.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4 3 10
1 1 8
Output
0.62500000000
Input
4
7 20 15 10
7 20 15 10
Output
0.31901840491
Input
2
10 20
10 1
Output
1.00000000000
----------------------------------------------------------------------------------------------------
F. Bear and Chemistry
time limit per test: 6 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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