Codeforces Round 887 (Div. 1)


A. Ntarsis' Set
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
5 1
1 2 4 5 6
5 3
1 3 5 6 7
4 1000
2 3 4 5
9 1434
1 4 7 9 12 15 17 18 20
10 4
1 3 5 7 9 11 13 15 17 19
10 6
1 4 7 10 13 16 19 22 25 28
10 150000
1 3 4 5 10 11 12 13 14 15
Output
3
9
1
12874
16
18
1499986
----------------------------------------------------------------------------------------------------
B. Imbalanced Arrays
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1
1
4
1 4 3 4
3
0 1 0
4
4 3 2 1
3
1 3 1
Output
YES
1 
NO
YES
-3 1 -2 
YES
4 2 -1 -3 
YES
-1 3 -1
----------------------------------------------------------------------------------------------------
C. Ina of the Mountain
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
4 3
1 2 1 3
7 3
1 2 3 1 3 2 1
Output
2
4
----------------------------------------------------------------------------------------------------
D. Miriany and Matchstick
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
10 1
ABBAAABBAA
4 5
AAAA
9 17
BAAABBAAB
4 9
ABAB
Output
NO
YES
BABB
YES
ABABAABAB
NO
----------------------------------------------------------------------------------------------------
E. Rivalries
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
7
5
1 4 1 3 3
5
1 4 1 8 8
5
2 1 1 1 2
8
3 2 3 5 2 2 5 3
8
1 1 1 1 4 3 3 3
10
1 9 5 9 8 1 5 8 9 1
16
1 1 1 1 5 5 5 5 9 9 9 9 7 7 7 7
Output
2 4 2 3 3
3 4 3 8 8
2 1 2 1 2
4 2 4 5 5 2 5 4
1 2 2 1 4 3 2 3
7 9 5 9 8 9 5 8 9 7
1 8 8 1 5 8 8 5 9 9 9 9 7 8 8 7
----------------------------------------------------------------------------------------------------
F. Panda Meetups
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
0 6 3
4 2 -5
7 4 -6
10 5 100
10 8 7
Output
0
3
3
3
10
Input
5
0 6 3
4 2 -5
7 4 -6
10 5 100
11 8 7
Output
0
3
3
3
9
Input
7
0 8 6
2 7 -2
3 1 -6
5 3 -8
7 3 -3
8 0 -2
8 2 1
Output
0
0
6
6
6
6
7
Input
4
0 0 -3
0 0 2
0 0 4
0 0 -10
Output
0
2
3
6
----------------------------------------------------------------------------------------------------
