Educational Codeforces Round 133 (Rated for Div. 2)


A. 2-3 Moves
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
2
2
3
Output
2
1 2
2 1
3
1 2 3
3 2 1
3 1 2
----------------------------------------------------------------------------------------------------
C. Robot in a Hallway
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3
0 0 1
4 3 2
5
0 4 8 12 16
2 6 10 14 18
4
0 10 10 10
10 10 10 10
2
0 0
0 0
Output
5
19
17
3
----------------------------------------------------------------------------------------------------
D. Chip Move
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8 1
Output
1 1 2 2 3 4 5 6 
Input
10 2
Output
0 1 0 1 1 1 1 2 2 2 
----------------------------------------------------------------------------------------------------
E. Swap and Maximum Block
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
-3 5 -3 2 8 -20 6 -1
3
1
0
1
Output
18
8
13
----------------------------------------------------------------------------------------------------
F. Bags with Balls
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
2 3 8
1 1 1
1 5 10
3 7 2000
1337666 42424242 2000
Output
1028
1
3
729229716
652219904
----------------------------------------------------------------------------------------------------
