Codeforces Round 681 (Div. 2, based on VK Cup 2019-2020 - Final)


A. Kids Seating
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2
3
4
Output
6 4
4 6 10
14 10 12 8
----------------------------------------------------------------------------------------------------
B. Saving the City
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 1
01000010
5 1
01101110
Output
2
6
----------------------------------------------------------------------------------------------------
C. The Delivery Dilemma
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4
3 7 4 5
2 1 2 4
4
1 2 3 4
3 3 3 3
2
1 2
10 10
2
10 10
1 2
Output
5
3
2
3
----------------------------------------------------------------------------------------------------
D. Extreme Subtraction
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
4 4
1 2 4
2 3
1 1 2
1 3 4
Output
9
4
6
----------------------------------------------------------------------------------------------------
F. Identify the Operations
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
5 3
1 2 3 4 5
3 2 5
4 3
4 3 2 1
4 3 1
7 4
1 4 7 3 6 2 5
3 2 4 5
Output
2
0
4
----------------------------------------------------------------------------------------------------
