Codeforces Beta Round 37


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

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

Examples
Input
2 10 3
100 3
99 1
Output
NO
Input
2 100 10
100 11
90 9
Output
YES
19 2
0 1
10 2
----------------------------------------------------------------------------------------------------
C. Old Berland Language
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 3
Output
YES
0
10
110
Input
3
1 1 1
Output
NO
----------------------------------------------------------------------------------------------------
D. Lesson Timetable
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 1 1
1 2 3
Output
36
Input
3
1 1 1
1 1 1
Output
6
----------------------------------------------------------------------------------------------------
E. Trial for Chief
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
WBW
BWB
WBW
Output
2
Input
2 3
BBB
BWB
Output
1
----------------------------------------------------------------------------------------------------
