Educational Codeforces Round 67 (Rated for Div. 2)


A. Stickers and Toys
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
10 5 7
10 10 10
2 1 1
Output
6
1
2
----------------------------------------------------------------------------------------------------
B. Letters Shop
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9
arrayhead
5
arya
harry
ray
r
areahydra
Output
5
6
5
2
9
----------------------------------------------------------------------------------------------------
C. Vasya And Array
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 4
1 1 3
1 2 5
0 5 6
1 6 7
Output
YES
1 2 2 3 5 4 4
Input
4 2
1 1 4
0 2 3
Output
NO
----------------------------------------------------------------------------------------------------
D. Subarray Sorting
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
7
1 7 1 4 4 5 6
1 1 4 4 5 7 6
5
1 1 3 3 5
1 1 3 3 5
2
1 1
1 2
3
1 2 3
3 2 1
Output
YES
YES
NO
NO
----------------------------------------------------------------------------------------------------
E. Tree Painting
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9
1 2
2 3
2 5
2 6
1 4
4 9
9 7
9 8
Output
36
Input
5
1 2
1 3
2 4
2 5
Output
14
----------------------------------------------------------------------------------------------------
F. Expected Square Beauty
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 1 1
1 2 3
Output
166666673
Input
3
3 4 5
4 5 6
Output
500000010
----------------------------------------------------------------------------------------------------
G. Gang Up
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 2 4 2 3
3 3 3 3
1 2
2 3
Output
52
Input
3 3 4 2 3
3 2 2 3
1 2
2 3
2 3
Output
38
----------------------------------------------------------------------------------------------------
