Codeforces Round 162 (Div. 1)


A. Escape from Stones
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
llrlr
Output
3
5
4
2
1
Input
rrlll
Output
1
2
5
4
3
Input
lrlrr
Output
2
4
5
3
1
----------------------------------------------------------------------------------------------------
B. Good Sequences
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2 3 4 6 9
Output
4
Input
9
1 2 3 5 6 7 8 9 10
Output
4
----------------------------------------------------------------------------------------------------
C. Choosing Balls
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 3
1 -2 3 4 0 -1
1 2 1 2 1 1
5 1
-2 1
1 0
Output
20
9
4
Input
4 1
-3 6 -1 2
1 2 3 1
1 -1
Output
5
----------------------------------------------------------------------------------------------------
D. Colorful Stones
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
RBR
RGG
Output
5
Input
RGBB
BRRBRR
Output
19
Input
RRRRRRRRRR
RRRRRRRR
Output
8
----------------------------------------------------------------------------------------------------
E. Roadside Trees
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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