Codeforces Round 283 (Div. 2)


A. Minimum Difficulty
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 4 6
Output
5
Input
5
1 2 3 4 5
Output
2
Input
5
1 2 3 7 8
Output
4
----------------------------------------------------------------------------------------------------
B. Secret Combination
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
579
Output
024
Input
4
2014
Output
0142
----------------------------------------------------------------------------------------------------
C. Removing Columns
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 10
codeforces
Output
0
Input
4 4
case
care
test
code
Output
2
Input
5 4
code
forc
esco
defo
rces
Output
4
----------------------------------------------------------------------------------------------------
D. Tennis Game
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 1 2 1
Output
2
1 3
3 1
Input
4
1 1 1 1
Output
3
1 4
2 2
4 1
Input
4
1 2 1 2
Output
0
Input
8
2 1 2 1 1 1 1 1
Output
3
1 6
2 3
6 1
----------------------------------------------------------------------------------------------------
E. Distributing Parts
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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