Educational Codeforces Round 101 (Rated for Div. 2)


A. Regular Bracket Sequence
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
()
(?)
(??)
??()
)?(?
Output
YES
NO
YES
YES
NO
----------------------------------------------------------------------------------------------------
B. Red and Blue
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
4
6 -5 7 -3
3
2 3 -4
2
1 1
4
10 -3 2 2
5
-1 -2 -3 -4 -5
5
-1 -2 -3 -4 -5
1
0
1
0
Output
13
13
0
0
----------------------------------------------------------------------------------------------------
C. Building a Fence
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
6 3
0 0 2 5 1 1
2 3
0 2
3 2
3 0 2
Output
YES
YES
NO
----------------------------------------------------------------------------------------------------
D. Ceil Divisions
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
3
4
Output
2
3 2
3 2
3
3 4
4 2
4 2
----------------------------------------------------------------------------------------------------
E. A Bit Similar
time limit per test: 2 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
7
4 2
0110
4 2
1001
9 3
010001110
9 3
101110001
10 3
0101110001
10 10
1111111111
11 10
11111111110
Output
YES
11
YES
00
YES
010
YES
101
NO
YES
0000000001
YES
0000000010
----------------------------------------------------------------------------------------------------
F. Power Sockets
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 2
3
Output
2
Input
3 3
4 3 3
Output
3
Input
3 5
4 3 4
Output
4
Input
2 10
5 7
Output
-1
----------------------------------------------------------------------------------------------------
