Codeforces Round 715 (Div. 2)


A. Average Height
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3
1 1 2
3
1 1 1
8
10 9 13 15 3 16 9 13
2
18 9
Output
1 1 2 
1 1 1 
13 9 13 15 3 9 16 10 
9 18 
----------------------------------------------------------------------------------------------------
B. TMT Document
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3
TMT
3
MTT
6
TMTMTT
6
TMTTTT
6
TTMMTT
Output
YES
NO
YES
NO
YES
----------------------------------------------------------------------------------------------------
C. The Sports Festival
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 1 2
Output
3
Input
1
5
Output
0
Input
6
1 6 3 3 6 3
Output
11
Input
6
104 943872923 6589 889921234 1000000000 69
Output
2833800505
----------------------------------------------------------------------------------------------------
D. Binary Literature
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1
00
11
01
3
011001
111010
010001
Output
010
011001010
----------------------------------------------------------------------------------------------------
E. Almost Sorted
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 1
1 2
3 3
6 5
3 4
Output
1 
-1
2 1 3 
1 2 4 3 5 6 
3 2 1 
----------------------------------------------------------------------------------------------------
F. Complete the MST
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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