Codeforces Round 885 (Div. 2)


A. Vika and Her Friends
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
2 2 1
1 1
1 2
2 2 2
1 1
2 2
2 2
1 2 1
1 1
1 2
5 5 4
3 3
1 1
1 5
5 1
5 5
2 2 2
1 1
2 1
1 2
3 4 1
1 2
3 3
Output
YES
NO
YES
NO
YES
YES
----------------------------------------------------------------------------------------------------
B. Vika and the Bridge
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
5 2
1 1 2 1 1
7 3
1 2 3 3 3 2 1
6 6
1 2 3 4 5 6
8 4
1 2 3 4 2 3 1 4
3 1
1 1 1
Output
0
1
2
2
0
----------------------------------------------------------------------------------------------------
C. Vika and Price Tags
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9
4
0 0 0 0
1 2 3 4
3
1 2 3
1 2 3
2
1 2
2 1
6
100 23 53 11 56 32
1245 31 12 6 6 6
7
1 2 3 4 5 6 7
7 6 5 4 3 2 1
3
4 0 2
4 0 2
3
2 5 2
1 3 4
2
6 1
4 2
2
0 0
0 3
Output
YES
YES
NO
NO
YES
YES
NO
YES
YES
----------------------------------------------------------------------------------------------------
D. Vika and Bonuses
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
1 3
11 3
0 179
5 1000000000
723252212 856168102
728598293 145725253
Output
4
33
0
9999999990
1252047198518668448
106175170582793129
----------------------------------------------------------------------------------------------------
E. Vika and Stone Skipping
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 2 179
2 3
Output
1
2
Input
7 5 998244353
2 13 1 44 179
Output
2
4
4
8
16
Input
1000000000 10 179
58989 49494 8799 9794 97414 141241 552545 145555 548959 774175
Output
120
4
16
64
111
43
150
85
161
95
----------------------------------------------------------------------------------------------------
F. Vika and Wiki
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 2 1 2
Output
2
Input
2
0 0
Output
0
Input
1
14
Output
1
Input
8
0 1 2 3 4 5 6 7
Output
5
----------------------------------------------------------------------------------------------------
