Educational Codeforces Round 164 (Rated for Div. 2)


A. Painting the Ribbon
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
1 1 1
5 1 1
5 2 1
5 2 2
5 5 3
Output
NO
NO
YES
NO
YES
----------------------------------------------------------------------------------------------------
B. Make It Ugly
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
3
73
31
2
5
3516
3982
Output
71
33
5
2
3912
3586
----------------------------------------------------------------------------------------------------
D. Colored Balls
time limit per test: 2 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
3
1 1 2
Output
11
Input
1
5
Output
5
Input
4
1 3 3 7
Output
76
----------------------------------------------------------------------------------------------------
E. Chain Reaction
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
5 2 7
Output
10 6 4 3 2 2 1 
Input
4
7 7 7 7
Output
7 4 3 2 2 2 1 
Input
10
1 9 7 6 2 4 7 8 1 3
Output
17 9 5 4 3 3 3 2 1 
----------------------------------------------------------------------------------------------------
F. Unique Strings
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 1 0
Output
1
Input
3 1 2
Output
3
Input
5 1 1
Output
3
Input
6 2 2
Output
7
Input
24 3 11
Output
498062
----------------------------------------------------------------------------------------------------
