Codeforces Round 799 (Div. 4)


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

Examples
Input
4
2 3 4 1
10000 0 1 2
500 600 400 300
0 9999 10000 9998
Output
2
0
1
3
----------------------------------------------------------------------------------------------------
B. All Distinct
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
6
2 2 2 3 3 3
5
9 1 9 9 1
4
15 16 16 15
4
10 100 1000 10000
Output
2
1
2
4
----------------------------------------------------------------------------------------------------
C. Where's the Bishop?
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
.....#..
#...#...
.#.#....
..#.....
.#.#....
#...#...
.....#..
......#.
#.#.....
.#......
#.#.....
...#....
....#...
.....#..
......#.
.......#
.#.....#
..#...#.
...#.#..
....#...
...#.#..
..#...#.
.#.....#
#.......
Output
4 3
2 2
4 5
----------------------------------------------------------------------------------------------------
D. The Clock
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
03:12 360
00:00 1
13:22 2
15:15 10
11:11 1440
22:30 27
Output
1
16
10
0
1
1
----------------------------------------------------------------------------------------------------
E. Binary Deque
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
3 1
1 0 0
3 1
1 1 0
9 3
0 1 0 1 1 1 0 0 1
6 4
1 1 1 1 1 1
5 1
0 0 1 1 0
16 2
1 1 0 0 1 0 0 1 1 0 0 0 0 0 1 1
6 3
1 0 1 0 0 0
Output
0
1
3
2
2
7
-1
----------------------------------------------------------------------------------------------------
F. 3SUM
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
4
20 22 19 84
4
1 11 1 2022
4
1100 1100 1100 1111
5
12 34 56 78 90
4
1 9 8 4
6
16 38 94 25 18 99
Output
YES
YES
NO
NO
YES
YES
----------------------------------------------------------------------------------------------------
G. 2^Sort
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
4 2
20 22 19 84
5 1
9 5 3 2 1
5 2
9 5 3 2 1
7 2
22 12 16 4 3 22 12
7 3
22 12 16 4 3 22 12
9 3
3 9 12 3 9 12 3 9 12
Output
2
3
2
3
1
0
----------------------------------------------------------------------------------------------------
H. Gambling
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
5
4 4 3 4 4
5
11 1 11 1 11
1
1000000000
10
8 8 8 9 9 6 6 9 6 6
Output
4 1 5
1 2 2
1000000000 1 1
6 6 10
----------------------------------------------------------------------------------------------------
