Codeforces Round 202 (Div. 1)


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

Examples
Input
3
3 2 2
Output
4
Input
4
2 2 2 2
Output
3
----------------------------------------------------------------------------------------------------
B. Apple Tree
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
0 0 12 13 5 6
1 2
1 3
1 4
2 5
2 6
Output
6
----------------------------------------------------------------------------------------------------
C. Subset Sums
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3 5
5 -5 5 1 -4
2 1 2
4 2 1 4 5
2 2 5
? 2
+ 3 4
? 1
+ 2 1
? 2
Output
-3
4
9
----------------------------------------------------------------------------------------------------
D. Turtles
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 5
.....
.###.
.###.
.....
Output
1
Input
2 3
...
...
Output
1
----------------------------------------------------------------------------------------------------
E. Pilgrims
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8 5
7 2 5 4 8
1 2 1
2 3 2
1 4 1
4 5 2
1 6 1
6 7 8
6 8 10
Output
5 1
----------------------------------------------------------------------------------------------------
