VK Cup 2018 - Round 2


A. Mystical Mosaic
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 8
.#.#..#.
.....#..
.#.#..#.
#.#....#
.....#..
Output
Yes
Input
5 5
..#..
..#..
#####
..#..
..#..
Output
No
Input
5 9
........#
#........
..##.#...
.......#.
....#.#.#
Output
No
----------------------------------------------------------------------------------------------------
B. Three-level Laser
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4
1 3 5 7
Output
0.5
Input
10 8
10 13 15 16 17 19 20 22 24 25
Output
0.875
Input
3 1
2 5 10
Output
-1
----------------------------------------------------------------------------------------------------
C. Riverside Curio
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
0 1 0 3 0 2
Output
6
Input
5
0 1 2 1 2
Output
1
Input
5
0 1 1 2 2
Output
0
----------------------------------------------------------------------------------------------------
D. Contact ATC
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 1
-3 2
-3 3
-1 2
1 -3
3 -5
Output
3
Input
6 1
-3 2
-2 2
-1 2
1 -2
2 -2
3 -2
Output
9
----------------------------------------------------------------------------------------------------
E. Wardrobe
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3 6
3 2 5 1 2
1 1 0 1 0
Output
2
Input
2 2 5
3 6
1 1
Output
1
----------------------------------------------------------------------------------------------------
F. Minimal Subset Difference
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10
1 100 0
1 100 1
1 100 2
1 100 3
1 100 4
1 100 5
1 100 6
1 100 7
1 100 8
1 100 9
Output
9
28
44
58
70
80
88
94
98
100
Input
10
1 1000 0
1 1000 1
1 1000 2
1 1000 3
1 1000 4
1 1000 5
1 1000 6
1 1000 7
1 1000 8
1 1000 9
Output
135
380
573
721
830
906
955
983
996
1000
----------------------------------------------------------------------------------------------------
