Deltix Round, Autumn 2021 (open for everyone, rated, Div. 1 + Div. 2)


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

Examples
Input
5
3
6 4 2
5
1 2 3 4 5
1
10
3
2 3 4
15
8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
Output
50
46
10
26
35184372088846
----------------------------------------------------------------------------------------------------
B. William the Vigilant
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9 10
abcabcabc
1 a
1 b
2 c
3 a
4 b
5 c
8 a
9 b
1 c
4 a
Output
3
2
2
2
1
2
1
1
1
0
----------------------------------------------------------------------------------------------------
C. Complex Market Analysis
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
7 3
10 2 1 3 1 19 3
3 2
1 13 1
9 3
2 4 2 1 1 1 1 4 2
3 1
1 1 1
4 1
1 2 1 1
2 2
1 2
Output
2
0
4
0
5
0
----------------------------------------------------------------------------------------------------
D. Social Network
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
9 12
aaabccccc
4 a
4 b
2 b
5 a
1 b
6 b
5 c
2 a
1 a
5 a
6 b
7 b
Output
0
1
2
2
1
2
1
2
2
2
2
2
----------------------------------------------------------------------------------------------------
F. Interesting Sections
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 3 4 5
Output
9
Input
10
0 5 7 3 9 10 1 6 13 7
Output
18
----------------------------------------------------------------------------------------------------
G. A Stroll Around the Matrix
time limit per test: 6 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3 4
1 2 4 7 11
5 7 10
1 3 2
2 2 5
1 5 4
2 1 7
Output
98
128
219
229
Input
5 6 7
4 9 22 118 226
7 94 238 395 565 738
2 1 95
1 4 54
1 2 5
1 2 87
2 6 62
2 1 143
1 1 77
Output
3639
5122
5162
5617
7663
7806
7960
----------------------------------------------------------------------------------------------------
H. Pushing Robots
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 1
0 4
1
-1
8
1 0
2 0
1 1
2 1
1 2
2 2
1 3
2 3
Output
0
4
1
3
1
2
1
2
Input
2 1
0 4
2
-1
8
1 0
2 0
1 1
2 1
1 2
2 2
1 3
2 3
Output
0
4
1
3
2
3
3
4
Input
2 2
0 1
1 -1
-1 1
4
1 0
1 1
1 2
1 3
Output
0
0
-1
0
Input
1 3
0
3 -2 1
3
1 5
1 10
1 15
Output
1
4
5
Input
4 3
-8 -4 2 5
-1 3 0
1 -3 -4
2 -5 2
-1 -4 2
5
3 12
4 18
4 11
1 6
1 10
Output
6
9
6
-8
-9
----------------------------------------------------------------------------------------------------
