Codeforces Round 497 (Div. 1)


A. Reorder the Array
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
10 1 1 1 5 5 3
Output
4
Input
5
1 1 1 1 1
Output
0
----------------------------------------------------------------------------------------------------
B. Pave the Parallelepiped
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 1 1
1 6 1
2 2 2
100 100 100
Output
1
4
4
165
----------------------------------------------------------------------------------------------------
C. Guess two numbers
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
0
Output
4 3
3 4
3 3
1 5
2 4
----------------------------------------------------------------------------------------------------
D. Ants
time limit per test: 3 seconds
memory limit per test: 768 megabytes
input: standard input
output: standard output

Examples
Input
6
1 2
3 1
4 1
5 2
6 2
3
2 6 3 4
1 6 6 5
1 4 5 2
Output
YES
2
1
2
Input
5
1 2
1 3
1 4
1 5
2
2 3 4 5
3 4 5 2
Output
NO
----------------------------------------------------------------------------------------------------
E. Mini Metro
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3 10
2 4 10
3 3 9
4 2 8
Output
2
Input
4 10 5
1 1 1
1 0 1
0 5 8
2 7 100
Output
12
----------------------------------------------------------------------------------------------------
