Codeforces Round 364 (Div. 2)


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

Examples
Input
6
1 5 7 4 4 3
Output
1 3
6 2
4 5
Input
4
10 10 10 10
Output
1 2
3 4
----------------------------------------------------------------------------------------------------
B. Cells Not Under Attack
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
1 1
3 1
2 2
Output
4 2 0 
Input
5 2
1 5
5 1
Output
16 9 
Input
100000 1
300 400
Output
9999800001 
----------------------------------------------------------------------------------------------------
C. They Are Everywhere
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
AaA
Output
2
Input
7
bcAAcbc
Output
3
Input
6
aaBCCe
Output
5
----------------------------------------------------------------------------------------------------
D. 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
----------------------------------------------------------------------------------------------------
E. 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
----------------------------------------------------------------------------------------------------
F. 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
----------------------------------------------------------------------------------------------------
