Codeforces Round 637 (Div. 2) - Thanks, Ivan Belonogov!


A. Nastya and Rice
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
7 20 3 101 18
11 11 10 234 2
8 9 7 250 122
19 41 21 321 10
3 10 8 6 1
Output
Yes
No
Yes
No
Yes
----------------------------------------------------------------------------------------------------
B. Nastya and Door
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
8 6
1 2 4 1 2 4 1 2
5 3
3 2 3 2 1
10 4
4 3 4 3 2 3 2 1 0 1
15 7
3 7 4 8 2 3 4 5 21 2 3 4 2 1 3
7 5
1 2 3 4 5 6 1
Output
3 2
2 2
2 1
3 1
2 3
----------------------------------------------------------------------------------------------------
C. Nastya and Strange Generator
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
5
2 3 4 5 1
1
1
3
1 3 2
4
4 2 3 1
5
1 5 2 4 3
Output
Yes
Yes
No
Yes
No
----------------------------------------------------------------------------------------------------
D. Nastya and Scoreboard
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 7
0000000
Output
8
Input
2 5
0010010
0010010
Output
97
Input
3 5
0100001
1001001
1010011
Output
-1
----------------------------------------------------------------------------------------------------
E. Nastya and Unexpected Guest
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
15 5
0 3 7 14 15
11 11
Output
45
Input
13 4
0 3 7 13
9 9
Output
-1
----------------------------------------------------------------------------------------------------
F. Nastya and Time Machine
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2
2 3
2 4
4 5
Output
13
1 0
2 1
3 2
3 1
2 2
4 3
4 1
5 2
5 1
4 2
2 3
2 0
1 1
----------------------------------------------------------------------------------------------------
