Codeforces Round 448 (Div. 2)


A. Pizza Separation
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
90 90 90 90
Output
0
Input
3
100 100 160
Output
40
Input
1
360
Output
360
Input
4
170 30 150 10
Output
0
----------------------------------------------------------------------------------------------------
B. XK Segments
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2 1
1 3 5 7
Output
3
Input
4 2 0
5 3 1 7
Output
4
Input
5 3 1
3 3 3 3 3
Output
25
----------------------------------------------------------------------------------------------------
C. Square Subsets
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 1 1 1
Output
15
Input
4
2 2 2 2
Output
7
Input
5
1 2 4 5 8
Output
7
----------------------------------------------------------------------------------------------------
D. String Mark
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
abc
ddd
Output
5
Input
abcdef
abcdeg
Output
0
Input
abacaba
ubuduba
Output
64
----------------------------------------------------------------------------------------------------
E. Eyes Closed
time limit per test: 2.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4
1 1 2 2
1 2 2 3 3
2 1 2
1 1 2 3 4
2 1 2
Output
3.0000000
3.0000000
Input
10 5
1 1 1 1 1 2 2 2 2 2
1 1 5 6 10
2 1 5
1 1 5 6 10
1 1 5 6 10
2 6 10
Output
6.0000000
8.0400000
Input
10 10
1 2 3 4 5 6 7 8 9 10
1 1 5 6 10
1 1 5 6 10
2 1 5
1 1 3 6 9
2 1 3
1 5 7 8 10
1 1 1 10 10
2 1 5
2 7 10
2 1 10
Output
23.0000000
14.0000000
28.0133333
21.5733333
55.0000000
----------------------------------------------------------------------------------------------------
