Codeforces Round 380 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 2)


A. Interview with Oleg
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
aogogob
Output
a***b
Input
13
ogogmgogogogo
Output
***gmg***
Input
9
ogoogoogo
Output
*********
----------------------------------------------------------------------------------------------------
B. Spotlights
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 4
0 1 0 0
1 0 1 0
Output
9
Input
4 4
0 0 0 0
1 0 0 1
0 1 1 0
0 1 0 0
Output
20
----------------------------------------------------------------------------------------------------
C. Road to Cinema
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 1 8 10
10 8
5 7
11 9
3
Output
10
Input
2 2 10 18
10 4
20 6
5 3
Output
20
----------------------------------------------------------------------------------------------------
D. Sea Battle
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 1 2 1
00100
Output
2
4 2
Input
13 3 2 3
1000000010001
Output
2
7 11
----------------------------------------------------------------------------------------------------
E. Subordinates
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
2 0 2
Output
1
Input
5 3
1 0 0 4 1
Output
2
----------------------------------------------------------------------------------------------------
F. Financiers Game
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
1 3 1
Output
4
Input
5
-1 -2 -1 -2 -1
Output
0
Input
4
-4 -2 4 5
Output
-13
----------------------------------------------------------------------------------------------------
