Codeforces Round 730 (Div. 2)


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

Examples
Input
4
8 5
1 2
4 4
3 9
Output
3 1
1 0
0 0
6 3
----------------------------------------------------------------------------------------------------
B. Customising the Track
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3
1 2 3
4
0 1 1 0
10
8 3 6 11 5 2 1 7 10 4
Output
0
4
21
----------------------------------------------------------------------------------------------------
C. Need for Pink Slips
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
0.2 0.2 0.6 0.2
0.4 0.2 0.4 0.8
0.4998 0.4998 0.0004 0.1666
0.3125 0.6561 0.0314 0.2048
Output
1.532000000000
1.860000000000
5.005050776521
4.260163673896
----------------------------------------------------------------------------------------------------
D1. RPD and Rap Sheet (Easy Version)
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
5 2
0
0
1
Output
3
4
5
----------------------------------------------------------------------------------------------------
D2. RPD and Rap Sheet (Hard Version)
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
5 2
0
0
1
5 3
0
0
1
Output
3
4
5
1
4
6
----------------------------------------------------------------------------------------------------
E. The Final Pursuit
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1
0 1
2
0 1
1 2
2 3
3 0
3
0 1
0 5
0 7
1 2
1 4
2 5
2 6
3 5
3 6
3 7
4 6
4 7
Output
0 1
0 0
0 1 3 2
0 0 1 1
5 3 0 7 2 6 1 4
-1
----------------------------------------------------------------------------------------------------
