Codeforces Round 364 (Div. 1)


A. As Fast As Possible
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 10 1 2 5
Output
5.0000000000
Input
3 6 1 2 1
Output
4.7142857143
----------------------------------------------------------------------------------------------------
B. Connecting Universities
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
6 7
1 6
2 1 6
2 3 5
3 4 9
4 6 4
4 6 5
4 5 1
3 1 3
Output
8
2
2 7
Input
6 7
1 6
2 3 1
1 2 2
1 3 3
4 5 4
3 6 5
4 6 6
1 5 7
Output
9
2
4 5
Input
5 4
1 5
2 1 3
3 2 1
3 4 4
4 5 2
Output
1
1
2
Input
2 3
1 2
1 2 734458840
1 2 817380027
1 2 304764803
Output
-1
----------------------------------------------------------------------------------------------------
D. Huffman Coding on Segment
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
1 2 1 3 1 2 1
5
1 7
1 3
3 5
2 4
4 4
Output
10
3
3
5
0
----------------------------------------------------------------------------------------------------
E. Cool Slogans
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
abc
Output
1
Input
5
ddddd
Output
5
Input
11
abracadabra
Output
3
----------------------------------------------------------------------------------------------------
