Educational Codeforces Round 145 (Rated for Div. 2)


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

Examples
Input
3
9546
0000
3313
Output
4
-1
6
----------------------------------------------------------------------------------------------------
B. Points on Plane
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1
3
5
975461057789971042
Output
0
1
2
987654321
----------------------------------------------------------------------------------------------------
C. Sum on Subarrays
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
3 2
2 0
2 2
4 6
Output
1 -3 1
-13 -42
-13 42
-3 -4 10 -2
----------------------------------------------------------------------------------------------------
D. Binary String Sorting
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
100
0
0101
00101101
1001101
11111
Output
1000000000001
0
1000000000000
2000000000001
2000000000002
0
----------------------------------------------------------------------------------------------------
E. Two Tanks
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4 4
-2 1 2
Output
0 0 0 0 0 
0 0 0 0 1 
0 0 1 1 2 
0 1 1 2 3 
1 1 2 3 4 
Input
3 9 5
1 -2 2
Output
0 0 0 0 0 0 
0 0 0 0 0 1 
0 1 1 1 1 2 
1 2 2 2 2 3 
2 3 3 3 3 4 
3 4 4 4 4 5 
4 5 5 5 5 6 
5 6 6 6 6 7 
6 7 7 7 7 8 
7 7 7 7 8 9 
----------------------------------------------------------------------------------------------------
F. Traveling in Berland
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3 5
3 4 4
1 2 2
5 7
1 3 2 5 1
2 1 1 1 2
4 3
1 2 1 3
2 2 2 2
3 2
2 2 2
1 2 1
Output
17 19 17 
13 12 12 12 14 
14 14 14 14 
8 8 8 
----------------------------------------------------------------------------------------------------
G. Prediction
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4 3
7 12 17 21
Output
24
Input
3 7
4 9 28
Output
4
Input
4 1
1 2 3 4
Output
0
Input
4 1
1 2 2 4
Output
12
Input
16 30
8 12 15 27 39 44 49 50 51 53 58 58 59 67 68 100
Output
527461297
----------------------------------------------------------------------------------------------------
