Codeforces Round 352 (Div. 1)


A. Recycling Bottles
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 1 1 2 0 0
3
1 1
2 1
2 3
Output
11.084259940083
Input
5 0 4 2 2 0
5
5 2
3 0
5 5
3 5
3 3
Output
33.121375178000
----------------------------------------------------------------------------------------------------
B. Robin Hood
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 1
1 1 4 2
Output
2
Input
3 1
2 2 2
Output
0
----------------------------------------------------------------------------------------------------
C. Ultimate Weirdness of an Array
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 6 3
Output
6
----------------------------------------------------------------------------------------------------
D. Roads in Yusland
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 5
1 2
1 3
3 4
4 5
4 6
2 1 2
3 1 4
4 1 3
5 3 1
6 3 2
Output
8
----------------------------------------------------------------------------------------------------
E. Organizing a Race
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4
2 2 2
1 1 1 1
Output
4
Input
8 5
2 2 2 3 7 3 1
1 3 1 5 4 0 2 5
Output
7
----------------------------------------------------------------------------------------------------
