Codeforces Round 821 (Div. 2)


A. Consecutive Sum
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3 2
5 6 0
1 1
7
5 3
7 0 4 0 4
4 2
2 7 3 4
3 3
1000000000 1000000000 999999997
Output
11
7
15
10
2999999997
----------------------------------------------------------------------------------------------------
B. Rule of League
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
5 2 0
8 1 2
3 0 0
2 0 1
6 3 0
Output
1 1 4 4
-1
-1
2 
-1
----------------------------------------------------------------------------------------------------
C. Parity Shuffle Sorting
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2
7 8
5
1 1000000000 3 0 5
1
0
Output
0
2
3 4
1 2
0
----------------------------------------------------------------------------------------------------
D1. Zero-One (Easy Version)
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
5 8 7
01001
00101
5 7 2
01000
11011
7 8 3
0111001
0100001
5 10 1
01100
01100
Output
8
-1
6
0
----------------------------------------------------------------------------------------------------
D2. Zero-One (Hard Version)
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
6
5 8 9
01001
00101
6 2 11
000001
100000
5 7 2
01000
11011
7 8 3
0111001
0100001
6 3 4
010001
101000
5 10 1
01100
01100
Output
8
10
-1
6
7
0
----------------------------------------------------------------------------------------------------
E. Conveyor
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
1 1 0
5 1 3
0 0 0
2 4 5
2 0 2
1547748756 100 111
Output
NO
YES
YES
NO
YES
YES
----------------------------------------------------------------------------------------------------
