Codeforces Round 284 (Div. 1)


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

Examples
Input
1 1
-1 -1
2
0 1 0
1 0 0
Output
2
Input
1 1
-1 -1
3
1 0 0
0 1 0
1 1 -3
Output
2
----------------------------------------------------------------------------------------------------
B. Name That Tune
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2
50 2
10 1
Output
1.500000000
Input
2 2
0 2
100 2
Output
1.000000000
Input
3 3
50 3
50 2
25 2
Output
1.687500000
Input
2 2
0 2
0 2
Output
1.000000000
----------------------------------------------------------------------------------------------------
C. Array and Operations
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
8 3 8
1 2
2 3
Output
0
Input
3 2
8 12 8
1 2
2 3
Output
2
----------------------------------------------------------------------------------------------------
D. Traffic Jams in the Land
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10
2 5 3 2 3 5 3 4 2 4
10
C 10 6
A 2 6
A 1 3
C 3 4
A 3 11
A 4 9
A 5 6
C 7 3
A 8 10
A 2 5
Output
5
3
14
6
2
4
4
----------------------------------------------------------------------------------------------------
E. Stairs and Lines
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
0 1 0 0 0 0 0
Output
1
Input
0 2 0 0 0 0 0
Output
7
Input
1 1 1 0 0 0 0
Output
9
Input
5 1 0 3 0 0 1
Output
411199181
----------------------------------------------------------------------------------------------------
