Educational Codeforces Round 149 (Rated for Div. 2)


A. Grasshopper on a Line
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
10 2
10 3
3 4
Output
2
7 3
1
10
1
3
----------------------------------------------------------------------------------------------------
B. Comparison String
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
4
<<>>
4
>><<
5
>>>>>
7
<><><><
Output
3
3
6
2
----------------------------------------------------------------------------------------------------
C. Best Binary String
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
??01?
10100
1??10?
0?1?10?10
Output
00011
10100
111101
011110010
----------------------------------------------------------------------------------------------------
D. Bracket Coloring
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
8
((())))(
4
(())
4
))((
3
(()
Output
2
2 2 2 1 2 2 2 1
1
1 1 1 1
1
1 1 1 1
-1
----------------------------------------------------------------------------------------------------
E. Playoff Fixing
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 2 3 4
Output
0
Input
2
1 3 4 2
Output
1
Input
1
-1 -1
Output
2
Input
2
-1 -1 -1 -1
Output
16
Input
3
-1 -1 -1 -1 2 -1 -1 -1
Output
768
Input
0
1
Output
1
----------------------------------------------------------------------------------------------------
F. Editorial for Two
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
5 4
1 10 1 1 1
5 3
1 20 5 15 3
5 3
1 20 3 15 5
10 6
10 8 20 14 3 8 6 4 16 11
10 5
9 9 2 13 15 19 4 9 13 12
1 1
1
Output
2
6
5
21
18
1
----------------------------------------------------------------------------------------------------
