Educational Codeforces Round 109 (Rated for Div. 2)


A. Potion-making
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3
100
25
Output
100
1
4
----------------------------------------------------------------------------------------------------
B. Permutation Sort
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4
1 3 2 4
3
1 2 3
5
2 1 4 5 3
Output
1
0
2
----------------------------------------------------------------------------------------------------
C. Robot Collisions
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
7 12
1 2 3 4 9 10 11
R R L L R R R
2 10
1 6
R R
2 10
1 3
L L
1 10
5
R
7 8
6 1 7 2 3 5 4
R L R L L L L
Output
1 1 1 1 2 -1 2 
-1 -1 
2 2 
-1 
-1 2 7 3 2 7 3 
----------------------------------------------------------------------------------------------------
D. Armchairs
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
7
1 0 0 1 0 0 1
Output
3
Input
6
1 1 1 0 0 0
Output
9
Input
5
0 0 0 0 0
Output
0
----------------------------------------------------------------------------------------------------
E. Assimilation IV
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 5
1 4 4 3 4
1 4 1 4 2
1 4 4 4 3
Output
166374062
----------------------------------------------------------------------------------------------------
F. Goblins And Gnomes
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5 4 4
1 2
2 3
4 3
5 3
100 1
200 5
10 10
100 1
Output
6
-2 -3 0 0 0 0 
Input
5 4 4
1 2
2 3
4 3
5 3
100 100
200 5
10 10
100 1
Output
6
0 -3 0 0 1 0
Input
5 10 1
1 2
1 3
1 4
1 5
5 2
5 3
5 4
4 2
4 3
2 3
100 100
Output
6
1 2 3 4 5 0
----------------------------------------------------------------------------------------------------
