Educational Codeforces Round 151 (Rated for Div. 2)


A. Forbidden Integer
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
10 3 2
5 2 1
4 2 1
7 7 3
6 1 1
Output
YES
6
3 1 1 1 1 3
NO
YES
2
2 2
YES
1
7
NO
----------------------------------------------------------------------------------------------------
B. Come Together
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 1
1 3
6 4
5 2
2 2
7 2
1 1
4 3
5 5
Output
3
1
6
----------------------------------------------------------------------------------------------------
C. Strong Password
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
88005553535123456
2
50
56
123412341234
3
111
444
1234
4
4321
4321
459
2
49
59
00010
2
10
11
Output
YES
NO
YES
NO
YES
----------------------------------------------------------------------------------------------------
D. Rating System
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4
3 -2 1 2
3
-1 -2 -1
2
4 2
7
5 1 -3 2 -1 -2 2
Output
3
0
25
6
----------------------------------------------------------------------------------------------------
E. Boxes and Balls
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 1
1 0 1 0
Output
3
Input
4 2
1 0 1 0
Output
2
Input
10 6
1 0 0 1 0 0 0 1 1 1
Output
69
----------------------------------------------------------------------------------------------------
F. Swimmers in the Pool
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
9 18
2
1 2
Output
3
Input
12 13
3
4 2 6
Output
10
Input
1 1000000000
3
100000 150000 200000
Output
997200007
----------------------------------------------------------------------------------------------------
