Educational Codeforces Round 44 (Rated for Div. 2)


A. Chess Placing
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
1 2 6
Output
2
Input
10
1 2 3 4 5
Output
10
----------------------------------------------------------------------------------------------------
B. Switches and Lamps
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 5
10101
01000
00111
10000
Output
YES
Input
4 5
10100
01000
00110
00101
Output
NO
----------------------------------------------------------------------------------------------------
C. Liebig's Barrels
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2 1
2 2 1 2 3 2 2 3
Output
7
Input
2 1 0
10 10
Output
20
Input
1 2 1
5 2
Output
2
Input
3 2 1
1 2 3 4 5 6
Output
0
----------------------------------------------------------------------------------------------------
D. Sand Fortress
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
Output
3
Input
6 8
Output
3
----------------------------------------------------------------------------------------------------
E. Pencils and Boxes
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 3 10
7 2 7 7 4 2
Output
YES
Input
6 2 3
4 5 3 13 4 10
Output
YES
Input
3 2 5
10 16 22
Output
NO
----------------------------------------------------------------------------------------------------
F. Isomorphic Strings
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 4
abacaba
1 1 1
1 4 2
2 1 3
2 4 3
Output
YES
YES
NO
YES
----------------------------------------------------------------------------------------------------
G. Team Players
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 0
2 3 4
Output
64
Input
4 1
2 3 4
1 0
Output
38
Input
6 4
1 5 3
0 3
3 5
5 4
4 3
Output
164
----------------------------------------------------------------------------------------------------
