Educational Codeforces Round 141 (Rated for Div. 2)


A. Make it Beautiful
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
4
3 3 6 6
2
10 10
5
1 2 3 4 5
3
1 4 4
Output
YES
3 6 3 6
NO
YES
2 4 1 5 3
YES
1 4 4
----------------------------------------------------------------------------------------------------
B. Matrix of Differences
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
2
3
Output
1 3
4 2
1 3 4
9 2 7
5 8 6
----------------------------------------------------------------------------------------------------
C. Yet Another Tournament
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
4 401
100 100 200 1
3 2
1 2 3
5 0
1 1 1 1 1
4 0
0 1 1 1
4 4
1 2 2 1
Output
1
2
6
4
1
----------------------------------------------------------------------------------------------------
D. Different Arrays
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
1 1 1 1
Output
3
Input
5
1 2 3 5 0
Output
7
----------------------------------------------------------------------------------------------------
E. Game of the Year
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3
1 1 1
2 3 1
1
1
1
4
1 4 3 2
3 3 4 1
Output
3
1 2 3 
1
1 
2
2 4 
----------------------------------------------------------------------------------------------------
F. Double Sort II
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
1 3 2 4 5
2 1 3 4 5
Output
1
2 
Input
2
1 2
1 2
Output
0
Input
4
1 3 4 2
4 3 2 1
Output
2
3 4 
----------------------------------------------------------------------------------------------------
G. Weighed Tree Radius
time limit per test: 6 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

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