CodeCraft-22 and Codeforces Round 795 (Div. 2)


A. Beat The Odds
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
5
2 4 3 6 8
6
3 5 9 7 1 3
Output
1
0
----------------------------------------------------------------------------------------------------
B. Shoe Shuffling
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
5
1 1 1 1 1
6
3 6 8 13 15 21
Output
5 1 2 3 4 
-1
----------------------------------------------------------------------------------------------------
C. Sum of Substrings
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4 0
1010
7 1
0010100
5 2
00110
Output
21
22
12
----------------------------------------------------------------------------------------------------
D. Max GEQ Sum
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4
-1 1 -1 2
5
-1 2 -3 2 -1
3
2 3 -1
Output
YES
YES
NO
----------------------------------------------------------------------------------------------------
E. Number of Groups
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
5
0 0 5
1 2 12
0 4 7
1 9 16
0 13 19
3
1 0 1
1 1 2
0 3 4
Output
2
3
----------------------------------------------------------------------------------------------------
F. K-Set Tree
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 2
1 2
1 3
Output
25
Input
7 2
1 2
2 3
2 4
1 5
4 6
4 7
Output
849
----------------------------------------------------------------------------------------------------
