Educational Codeforces Round 96 (Rated for Div. 2)


A. Number of Apartments
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
30
67
4
14
Output
2 2 2
7 5 3
-1
0 0 2
----------------------------------------------------------------------------------------------------
B. Barrels
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
1
4
Output
2
2 4
3 3
3 1
----------------------------------------------------------------------------------------------------
D. String Deletion
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
6
111010
1
0
1
1
2
11
6
101010
Output
3
1
1
1
3
----------------------------------------------------------------------------------------------------
E. String Reversal
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
aaaza
Output
2
Input
6
cbaabc
Output
0
Input
9
icpcsguru
Output
30
----------------------------------------------------------------------------------------------------
F. Realistic Gameplay
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 3
2 3 6
3 4 3
Output
9
Input
2 5
3 7 11
10 12 15
Output
30
Input
5 42
42 42 42
42 43 42
43 44 42
44 45 42
45 45 1
Output
-1
Input
1 10
100 111 1
Output
1
----------------------------------------------------------------------------------------------------
G. Yet Another DAG Problem
time limit per test: 2 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
3 2
2 1 4
1 3 2
Output
1 2 0
Input
5 4
1 2 1
2 3 1
1 3 6
4 5 8
Output
43 42 41 1337 1336
Input
5 5
1 2 1
2 3 1
3 4 1
1 5 1
5 4 10
Output
4 3 2 1 2
----------------------------------------------------------------------------------------------------
