Codeforces Round 938 (Div. 3)


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

Examples
Input
4
2 5 9
3 5 9
3 5 11
4 5 11
Output
9
14
15
20
----------------------------------------------------------------------------------------------------
B. Progressive Square
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3 2 3
3 9 6 5 7 1 10 4 8
3 2 3
3 9 6 5 7 1 11 4 8
2 100 100
400 300 400 500
3 2 3
3 9 6 6 5 1 11 4 8
4 4 4
15 27 7 19 23 23 11 15 7 3 19 23 11 15 11 15
Output
NO
YES
YES
NO
NO
----------------------------------------------------------------------------------------------------
C. Inhabitant of the Deep Sea
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
4 5
1 2 4 3
4 6
1 2 4 3
5 20
2 7 1 8 2
2 2
3 2
2 15
1 5
2 7
5 2
Output
2
3
5
0
2
2
----------------------------------------------------------------------------------------------------
D. Inaccurate Subsequence Search
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
7 4 2
4 1 2 3 4 5 6
1 2 3 4
7 4 3
4 1 2 3 4 5 6
1 2 3 4
7 4 4
4 1 2 3 4 5 6
1 2 3 4
11 5 3
9 9 2 2 10 9 7 6 3 6 3
6 9 7 8 10
4 1 1
4 1 5 6
6
Output
4
3
2
4
1
----------------------------------------------------------------------------------------------------
E. Long Inversions
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
5
00100
5
01000
7
1011101
3
000
2
10
Output
3
2
4
3
1
----------------------------------------------------------------------------------------------------
F. Unfair Game
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 1 1 0
1 0 1 2
2 2 2 0
3 3 2 0
0 9 9 9
Output
1
1
3
3
12
----------------------------------------------------------------------------------------------------
G. GCD on a grid
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 3
30 20 30
15 25 40
3 3
12 4 9
3 12 2
8 3 12
2 4
2 4 6 8
1 3 6 9
Output
10
3
1
----------------------------------------------------------------------------------------------------
H. The Most Reckless Defense
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
2 2 1
#.
##
1 2 1
2 2 1
#.
##
1 2 2
2 2 1
#.
##
1 2 500
3 3 2
#..
##.
.##
1 2 4
3 1 3
3 5 2
#.###
#.#.#
###.#
2 2 2
2 4 2
5 5 4
#....
#....
#....
#....
#####
3 2 142
4 5 9
2 5 79
1 3 50
Output
0
1
1491
11
8
1797
----------------------------------------------------------------------------------------------------
