Educational Codeforces Round 148 (Rated for Div. 2)


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

Examples
Input
3
codedoc
gg
aabaa
Output
YES
NO
NO
----------------------------------------------------------------------------------------------------
B. Maximum Sum
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
5 1
2 5 1 10 6
5 2
2 5 1 10 6
3 1
1 2 3
6 1
15 22 12 10 13 11
6 2
15 22 12 10 13 11
5 1
999999996 999999999 999999997 999999998 999999995
Output
21
11
3
62
46
3999999986
----------------------------------------------------------------------------------------------------
C. Contrast Value
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
5
1 3 3 3 7
2
4 2
4
1 1 1 1
7
5 4 2 1 0 0 4
Output
2
2
1
3
----------------------------------------------------------------------------------------------------
D1. Red-Blue Operations (Easy Version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 10
5 2 8 4
1 2 3 4 5 6 7 8 9 10
Output
3 4 5 6 7 8 8 10 8 12
Input
5 10
5 2 8 4 4
1 2 3 4 5 6 7 8 9 10
Output
3 4 5 6 7 8 9 8 11 8
Input
2 5
2 3
10 6 8 1 3
Output
10 7 8 3 3
----------------------------------------------------------------------------------------------------
D2. Red-Blue Operations (Hard Version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 10
5 2 8 4
1 2 3 4 5 6 7 8 9 10
Output
3 4 5 6 7 8 8 10 8 12
Input
5 10
5 2 8 4 4
1 2 3 4 5 6 7 8 9 10
Output
3 4 5 6 7 8 9 8 11 8
Input
2 5
2 3
10 6 8 1 3
Output
10 7 8 3 3
----------------------------------------------------------------------------------------------------
E. Combinatorics Problem
time limit per test: 4 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
5 8 2 3 100 2
Output
1283
----------------------------------------------------------------------------------------------------
F. Zombies
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3 10 3
0 2
1 7
4 7
Output
18
Input
3 2 10 3
0 2
1 7
4 7
Output
18
Input
3 1 10 3
0 2
1 7
4 7
Output
16
Input
2 1 20 6
11 13
2 14
Output
22
Input
5 3 7 4
4 6
0 3
4 7
1 5
2 7
Output
14
Input
6 3 9 4
3 9
4 9
2 5
0 5
6 9
2 3
Output
26
----------------------------------------------------------------------------------------------------
