Educational Codeforces Round 60 (Rated for Div. 2)


A. Best Subsegment
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
6 1 6 6 0
Output
2
----------------------------------------------------------------------------------------------------
B. Emotes
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 9 2
1 3 3 7 4 2
Output
54
Input
3 1000000000 1
1000000000 987654321 1000000000
Output
1000000000000000000
----------------------------------------------------------------------------------------------------
C. Magic Ship
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
0 0
4 6
3
UUU
Output
5
Input
0 3
0 0
3
UDD
Output
3
Input
0 0
0 1
1
L
Output
-1
----------------------------------------------------------------------------------------------------
D. Magic Gems
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
Output
5
Input
3 2
Output
3
----------------------------------------------------------------------------------------------------
E. Decypher the String
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
yzx
aab
baa
aba
Output
? baa
? aba
? aab
! xyz
----------------------------------------------------------------------------------------------------
F. Crisp String
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 3
abacaba
0 1 1
1 0 0
1 0 0
Output
7
Input
7 3
abacaba
1 1 1
1 0 0
1 0 0
Output
0
Input
7 4
bacadab
0 1 1 1
1 0 0 0
1 0 0 0
1 0 0 0
Output
5
Input
3 3
cbc
0 0 0
0 0 1
0 1 0
Output
0
----------------------------------------------------------------------------------------------------
G. Recursive Queries
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 5
3 1 4 2
2 1 1 2 1
2 3 4 4 1
Output
1 6 8 5 1 
----------------------------------------------------------------------------------------------------
