Codeforces Round 424 (Div. 2, rated, based on VK Cup Finals)


A. Unimodal Array
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
1 5 5 5 4 2
Output
YES
Input
5
10 20 30 20 10
Output
YES
Input
4
1 2 1 2
Output
NO
Input
7
3 3 3 3 3 3 3
Output
YES
----------------------------------------------------------------------------------------------------
B. Keyboard Layouts
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
qwertyuiopasdfghjklzxcvbnm
veamhjsgqocnrbfxdtwkylupzi
TwccpQZAvb2017
Output
HelloVKCup2017
Input
mnbvcxzlkjhgfdsapoiuytrewq
asdfghjklqwertyuiopzxcvbnm
7abaCABAABAcaba7
Output
7uduGUDUUDUgudu7
----------------------------------------------------------------------------------------------------
C. Jury Marks
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 1
-5 5 0 20
10
Output
3
Input
2 2
-2000 -2000
3998000 4000000
Output
1
----------------------------------------------------------------------------------------------------
D. Office Keys
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 4 50
20 100
60 10 40 80
Output
50
Input
1 2 10
11
15 7
Output
7
----------------------------------------------------------------------------------------------------
E. Cards Sorting
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
6 3 1 2
Output
7
Input
1
1000
Output
1
Input
7
3 3 3 3 3 3 3
Output
7
----------------------------------------------------------------------------------------------------
F. Bamboo Partition
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 4
1 3 5
Output
3
Input
3 40
10 30 50
Output
32
----------------------------------------------------------------------------------------------------
