Codeforces Beta Round 87 (Div. 1 Only)


A. Party
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
-1
1
2
1
-1
Output
3
----------------------------------------------------------------------------------------------------
B. Lawnmower
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 5
GWGGW
GGWGG
GWGGG
WGGGG
Output
11
Input
3 3
GWW
WWW
WWG
Output
7
Input
1 1
G
Output
0
----------------------------------------------------------------------------------------------------
C. Plumber
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2
13
..
Output
2
Input
3 1
1
4
.
Output
0
Input
2 2
3.
.1
Output
1
----------------------------------------------------------------------------------------------------
D. Unambiguous Arithmetic Expression
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1+2*3
Output
2
Input
03+-30+40
Output
3
Input
5//4
Output
0
Input
5/0
Output
1
Input
1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
Output
100728
----------------------------------------------------------------------------------------------------
E. Linear Kingdom Races
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 4
3
2
3
2
1
2
3
1 2 5
2 3 5
3 5 3
7 7 5
Output
4
Input
2 1
0
3
1 2 5
Output
2
Input
3 1
10
10
10
1 3 10
Output
0
----------------------------------------------------------------------------------------------------
