Codeforces Round 494 (Div. 3)


A. Polycarp's Pockets
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
1 2 4 3 3 2
Output
2
Input
1
100
Output
1
----------------------------------------------------------------------------------------------------
B. Binary String Constructing
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2 1
Output
1100
Input
3 3 3
Output
101100
Input
5 3 6
Output
01010100
----------------------------------------------------------------------------------------------------
C. Intense Heat
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3
3 4 1 2
Output
2.666666666666667
----------------------------------------------------------------------------------------------------
D. Coins and Queries
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 4
2 4 8 2 4
8
5
14
10
Output
1
-1
3
2
----------------------------------------------------------------------------------------------------
E. Tree Constructing
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 3 3
Output
YES
3 1
4 1
1 2
5 2
2 6
Input
6 2 3
Output
NO
Input
10 4 3
Output
YES
2 9
2 10
10 3
3 1
6 10
8 2
4 3
5 6
6 7
Input
8 5 3
Output
YES
2 5
7 2
3 7
3 1
1 6
8 7
4 3
----------------------------------------------------------------------------------------------------
F. Abbreviation
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
to be or not to be
Output
12
Input
10
a ab a a b ab a a b c
Output
13
Input
6
aa bb aa aa bb bb
Output
11
----------------------------------------------------------------------------------------------------
