Codeforces Round 532 (Div. 2)


A. Roman and Browser
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
1 1 -1 1
Output
2
Input
14 3
-1 1 -1 -1 1 -1 -1 1 -1 -1 1 -1 -1 1
Output
9
----------------------------------------------------------------------------------------------------
B. Build a Contest
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 11
2 3 1 2 2 2 3 2 2 3 1
Output
00100000001
Input
4 8
4 1 3 3 2 3 3 3
Output
00001000
----------------------------------------------------------------------------------------------------
C. NN and the Optical Illusion
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 1
Output
6.4641016
Input
6 1
Output
1.0000000
Input
100 100
Output
3.2429391
----------------------------------------------------------------------------------------------------
D. Dasha and Chess
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
999 999
1 1
1 2
2 1
2 2
1 3
2 3
<...>
26 13
26 14
26 15
26 16
1 700 800
2 1 2
<...>
-1 -1 -1
Output
999 998
999 997
<...>
999 26
----------------------------------------------------------------------------------------------------
E. Andrew and Taxi
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 6
2 1 1
5 2 6
2 3 2
3 4 3
4 5 5
1 5 4
Output
2 2
1 3 
Input
5 7
2 1 5
3 2 3
1 3 3
2 4 1
4 3 5
5 4 1
1 5 3
Output
3 3
3 4 7 
----------------------------------------------------------------------------------------------------
F. Ivan and Burgers
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
7 2 3 4
3
1 4
2 3
1 3
Output
7
3
7
Input
5
12 14 23 13 7
15
1 1
1 2
1 3
1 4
1 5
2 2
2 3
2 4
2 5
3 3
3 4
3 5
4 4
4 5
5 5
Output
12
14
27
27
31
14
25
26
30
23
26
29
13
13
7
----------------------------------------------------------------------------------------------------
