Educational Codeforces Round 35 (Rated for Div. 2)


A. Nearest Minimums
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
3 3
Output
1
Input
3
5 6 5
Output
2
Input
9
2 1 3 5 4 1 2 3 1
Output
3
----------------------------------------------------------------------------------------------------
B. Two Cakes
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
2 2 3
Output
YES
Input
4 2 3
Output
NO
----------------------------------------------------------------------------------------------------
D. Inversion Counting
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 3
2
1 2
2 3
Output
odd
even
Input
4
1 2 4 3
4
1 1
1 4
1 4
2 3
Output
odd
odd
odd
even
----------------------------------------------------------------------------------------------------
E. Stack Sorting
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3
3 2 1
Output
3 2 1 5 4 
Input
5 3
2 3 1
Output
-1
Input
5 1
3
Output
3 2 1 5 4 
Input
5 2
3 4
Output
-1
----------------------------------------------------------------------------------------------------
F. Tree Destruction
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2
1 3
Output
3
2 3 3
2 1 1
Input
5
1 2
1 3
2 4
2 5
Output
9
3 5 5
4 3 3
4 1 1
4 2 2
----------------------------------------------------------------------------------------------------
G. Mass Change Queries
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 3 4 5
3
3 5 3 5
1 5 5 1
1 5 1 5
Output
5 2 5 4 5 
----------------------------------------------------------------------------------------------------
