Codeforces Round 870 (Div. 2)


A. Trust Nobody
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
2
1 2
2
2 2
2
0 0
1
1
1
0
5
5 5 3 3 5
6
5 3 6 6 3 5
Output
1
-1
0
-1
0
3
4
----------------------------------------------------------------------------------------------------
B. Lunatic Never Content
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2
1 2
8
3 0 1 2 0 3 2 1
1
0
3
100 1 1000000000
Output
1
2
0
999999900
----------------------------------------------------------------------------------------------------
C. Dreaming of Freedom
time limit per test: 2.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3 2
4 2
5 3
1000000 1000000
1 1000000
Output
YES
NO
YES
NO
YES
----------------------------------------------------------------------------------------------------
D. Running Miles
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
5
5 1 4 2 3
4
1 1 1 1
6
9 8 7 6 5 4
7
100000000 1 100000000 1 100000000 1 100000000
Output
8
1
22
299999996
----------------------------------------------------------------------------------------------------
E. Walk the Runway
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 5
10 10 10 10 10
1 2 3 4 5
1 5 2 3 4
2 3 4 5 1
Output
30
Input
3 5
10 10 10 10 50
1 2 3 4 5
1 5 2 3 4
2 3 4 5 1
Output
50
Input
1 1
1000000000
1
Output
1000000000
Input
5 5
1000000000 1000000000 1000000000 1000000000 1000000000
5 4 3 2 1
5 4 3 2 1
5 4 3 2 1
5 4 3 2 1
5 4 3 2 1
Output
5000000000
Input
1 3
1 2 3
3 3 3
Output
3
----------------------------------------------------------------------------------------------------
F. Fading into Fog
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
2
1 1 2.5 1
1.500000001 1.500000000 2 2
Output
? 0 1 -1
? 0.2 -0.2 0
! 1 3 2.5 0.500000001
----------------------------------------------------------------------------------------------------
