Codeforces Beta Round 24


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

Examples
Input
3
1 3 1
1 2 1
3 2 1
Output
1
Input
3
1 3 1
1 2 5
3 2 1
Output
2
Input
6
1 5 4
5 3 8
2 4 15
1 6 16
2 3 23
4 6 42
Output
39
Input
4
1 2 9
2 3 8
3 4 7
4 1 5
Output
0
----------------------------------------------------------------------------------------------------
B. F1 Champions
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3
Hamilton
Vettel
Webber
2
Webber
Vettel
2
Hamilton
Vettel
Output
Vettel
Hamilton
Input
2
7
Prost
Surtees
Nakajima
Schumacher
Button
DeLaRosa
Buemi
8
Alonso
Prost
NinoFarina
JimClark
DeLaRosa
Nakajima
Patrese
Surtees
Output
Prost
Prost
----------------------------------------------------------------------------------------------------
C. Sequence of points
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4
0 0
1 1
2 3
-5 3
Output
14 0
Input
3 1
5 5
1000 1000
-1000 1000
3 100
Output
1995 1995
----------------------------------------------------------------------------------------------------
D. Broken robot
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 10
10 4
Output
0.0000000000
Input
10 14
5 14
Output
18.0038068653
----------------------------------------------------------------------------------------------------
E. Berland collider
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
-5 9
0 1
5 -1
Output
1.00000000000000000000
Input
6
1 3
2 3
3 3
4 -3
5 -1
6 -100
Output
0.02912621359223301065
----------------------------------------------------------------------------------------------------
