Codeforces Round 471 (Div. 2)


A. Feed the cat
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
19 00
255 1 100 1
Output
25200.0000
Input
17 41
1000 6 15 11
Output
1365.0000
----------------------------------------------------------------------------------------------------
B. Not simply beatiful strings
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
ababa
Output
Yes
Input
zzcxx
Output
Yes
Input
yeee
Output
No
----------------------------------------------------------------------------------------------------
C. Sad powers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
1 4
9 9
5 7
12 29
137 591
1 1000000
Output
2
1
0
3
17
1111
----------------------------------------------------------------------------------------------------
D. Scissors
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 4 3
baabaab
aaaa
Output
Yes
1 5
Input
6 3 2
cbcbcb
bcc
Output
Yes
2 5
Input
7 5 3
aabbaaa
aaaaa
Output
No
----------------------------------------------------------------------------------------------------
E. Icicles
time limit per test: 2.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 4 3 5 1
Output
3
Input
4
1 2 1 1
Output
2
Input
2
2 1
Output
3
Input
2
1 2
Output
-1
----------------------------------------------------------------------------------------------------
F. Heaps
time limit per test: 2.5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

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