Codeforces Round 445 (Div. 2, based on Technocup 2018 Elimination Round 3)


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

Examples
Input
1 3 2 1 2 1
Output
YES
Input
1 1 1 1 1 99
Output
NO
----------------------------------------------------------------------------------------------------
B. Vlad and Cafes
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 3 2 1 2
Output
3
Input
6
2 1 2 2 4 1
Output
2
----------------------------------------------------------------------------------------------------
C. Petya and Catacombs
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
0 0
Output
2
Input
5
0 1 0 1 3
Output
3
----------------------------------------------------------------------------------------------------
D. Restoration of string
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
mail
ai
lru
cf
Output
cfmailru
Input
3
kek
preceq
cheburek
Output
NO
----------------------------------------------------------------------------------------------------
E. Maximum Element
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
Output
22
Input
5 3
Output
6
Input
6 3
Output
84
----------------------------------------------------------------------------------------------------
F. Symmetric Projections
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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