Technocup 2022 - Elimination Round 3


A. Life of a Flower
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3
1 0 1
3
0 1 1
4
1 0 0 1
1
0
Output
3
7
-1
1
----------------------------------------------------------------------------------------------------
B. Array Eversion
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
5
2 4 1 5 3
5
5 3 2 4 1
4
1 1 1 1
Output
1
2
0
----------------------------------------------------------------------------------------------------
C. Minimize Distance
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
5 1
1 2 3 4 5
9 3
-5 -10 -15 6 5 8 3 7 4
5 3
2 2 3 3 3
4 2
1000000000 1000000000 1000000000 1000000000
Output
25
41
7
3000000000
----------------------------------------------------------------------------------------------------
D. Yet Another Sorting Problem
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
1
1
2
2 2
2
2 1
3
1 2 3
3
2 1 3
3
3 1 2
4
2 1 4 3
Output
YES
YES
NO
YES
NO
YES
YES
----------------------------------------------------------------------------------------------------
E. Frequency Queries
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
3 3
1 1 1
1 2
3 1 1
3 1 2
3 2 1
5 5
1 2 1 1 2
1 1 2 2
3 1 1
2 1 2
4 1 1
4 2 1
4 2 2
Output
1 -1 1 
1 1 2 1 -1 
----------------------------------------------------------------------------------------------------
F. Non-equal Neighbours
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
2 2 2
Output
2
Input
2
2 3
Output
4
Input
3
1 1 1
Output
0
----------------------------------------------------------------------------------------------------
G. Poachers
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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