Educational Codeforces Round 40 (Rated for Div. 2)


A. Diagonal Walking
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
RUURU
Output
3
Input
17
UUURRRRRUUURURUUU
Output
13
----------------------------------------------------------------------------------------------------
B. String Typing
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
abcabca
Output
5
Input
8
abcdefgh
Output
8
----------------------------------------------------------------------------------------------------
C. Matrix Walk
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
1 2 3 6 9 8 5 2
Output
YES
3 3
Input
6
1 2 1 2 5 3
Output
NO
Input
2
1 10
Output
YES
4 9
----------------------------------------------------------------------------------------------------
D. Fight Against Traffic
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
2 100
3 10
50 150
Output
6.000000000000000
Input
3 9
5 5 30
6 6 10
Output
40.000000000000000
Input
2 12
1 3
10 15
Output
1.666666666666667
----------------------------------------------------------------------------------------------------
F. Runner's Problem
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 5
1 3 4
2 2 3
Output
2
----------------------------------------------------------------------------------------------------
G. Castle Defense
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 0 6
5 4 3 4 9
Output
5
Input
4 2 0
1 2 3 4
Output
6
Input
5 1 1
2 1 2 1 2
Output
3
----------------------------------------------------------------------------------------------------
H. Path Counting
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 2 2
Output
14 19 20 20 16 16 
Input
3
2 3
Output
8 13 6 9 
----------------------------------------------------------------------------------------------------
I. Yet Another String Matching Problem
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
abcdefa
ddcb
Output
2 3 3 3 
----------------------------------------------------------------------------------------------------
