Codeforces Round 152 (Div. 2)


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

Examples
Input
5
0 1
1 0
0 1
1 1
0 1
Output
3
----------------------------------------------------------------------------------------------------
B. Chilly Willy
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
Output
-1
Input
5
Output
10080
----------------------------------------------------------------------------------------------------
C. Robo-Footballer
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 10 13 10 3 1
Output
4.3750000000
Input
1 4 6 2 2 1
Output
-1
Input
3 10 15 17 9 2
Output
11.3333333333
----------------------------------------------------------------------------------------------------
D. Sweets for Everyone!
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 6
HSHSHS
Output
1
Input
14 100
...HHHSSS...SH
Output
0
Input
23 50
HHSS.......SSHHHHHHHHHH
Output
8
----------------------------------------------------------------------------------------------------
E. Piglet's Birthday
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 2 3
5
1 2 1
2 1 2
1 2 2
3 1 1
3 2 2
Output
0.000000000000
0.333333333333
1.000000000000
1.000000000000
2.000000000000
----------------------------------------------------------------------------------------------------
