Educational Codeforces Round 31


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

Examples
Input
2 2
86400 86398
Output
2
Input
2 86400
0 86400
Output
1
----------------------------------------------------------------------------------------------------
B. Japanese Crosswords Strike Back
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 4
1 3
Output
NO
Input
3 10
3 3 2
Output
YES
Input
2 10
1 3
Output
NO
----------------------------------------------------------------------------------------------------
C. Bertown Subway
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 1 3
Output
9
Input
5
1 5 4 3 2
Output
17
----------------------------------------------------------------------------------------------------
D. Boxes And Balls
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 3
Output
6
Input
4
2 3 4 5
Output
19
----------------------------------------------------------------------------------------------------
E. Binary Matrix
time limit per test: 3 seconds
memory limit per test: 16 megabytes
input: standard input
output: standard output

Examples
Input
3 4
1
A
8
Output
3
Input
2 8
5F
E3
Output
2
Input
1 4
0
Output
0
----------------------------------------------------------------------------------------------------
F. Anti-Palindromize
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
abacabac
1 1 1 1 1 1 1 1
Output
8
Input
8
abaccaba
1 2 3 4 5 6 7 8
Output
26
Input
8
abacabca
1 2 3 4 4 3 2 1
Output
17
----------------------------------------------------------------------------------------------------
