Codeforces Round 751 (Div. 2)


A. Two Subsequences
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
fc
aaaa
thebrightboiler
Output
c f
a aaa
b therightboiler
----------------------------------------------------------------------------------------------------
B. Divine Array
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
7
2 1 1 4 3 1 2
4
3 0
1 1
2 2
6 1
2
1 1
2
1 0
2 1000000000
Output
1
2
3
3
1
2
----------------------------------------------------------------------------------------------------
C. Array Elimination
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
4
4 4 4 4
4
13 7 25 19
6
3 5 3 1 7 1
1
1
5
0 0 0 0 0
Output
1 2 4
1 2
1
1
1 2 3 4 5
----------------------------------------------------------------------------------------------------
D. Frog Traveler
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
0 2 2
1 1 0
Output
2
1 0 
Input
2
1 1
1 0
Output
-1
Input
10
0 1 2 3 5 5 6 7 8 5
9 8 7 1 5 4 3 2 0 0
Output
3
9 4 0 
----------------------------------------------------------------------------------------------------
E. Optimal Insertion
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
3 4
1 2 3
4 3 2 1
3 3
3 2 1
1 2 3
5 4
1 3 5 3 1
4 3 6 1
Output
0
4
6
----------------------------------------------------------------------------------------------------
F. Difficult Mountain
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

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