Codeforces Round 367 (Div. 2)


A. Beru-taxi
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
0 0
2
2 0 1
0 2 2
Output
1.00000000000000000000
Input
1 3
3
3 3 2
-2 3 6
-2 7 10
Output
0.50000000000000000000
----------------------------------------------------------------------------------------------------
B. Interesting drink
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3 10 8 6 11
4
1
10
3
11
Output
0
4
1
5
----------------------------------------------------------------------------------------------------
C. Hard problem
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 2
ba
ac
Output
1
Input
3
1 3 1
aa
ba
ac
Output
1
Input
2
5 5
bbb
aaa
Output
-1
Input
2
3 3
aaa
aa
Output
-1
----------------------------------------------------------------------------------------------------
D. Vasiliy's Multiset
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10
+ 8
+ 9
+ 11
+ 6
+ 1
? 3
- 8
? 3
? 8
? 11
Output
11
10
14
13
----------------------------------------------------------------------------------------------------
E. Working routine
time limit per test: 2.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4 2
1 1 2 2
1 1 2 2
3 3 4 4
3 3 4 4
1 1 3 3 2 2
3 1 1 3 2 2
Output
4 4 3 3
4 4 3 3
2 2 1 1
2 2 1 1
Input
4 2 1
1 1
1 1
2 2
2 2
1 1 4 1 1 2
Output
2 2
1 1
2 2
1 1
----------------------------------------------------------------------------------------------------
