Codeforces Round 244 (Div. 2)


A. Police Recruits
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
-1 -1 1
Output
2
Input
8
1 -1 1 -1 -1 1 1 1
Output
1
Input
11
-1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1
Output
8
----------------------------------------------------------------------------------------------------
B. Prison Transfer
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3 3
2 3 1 1
Output
2
Input
1 1 1
2
Output
0
Input
11 4 2
2 2 0 7 3 2 2 4 9 1 4
Output
6
----------------------------------------------------------------------------------------------------
C. Checkposts
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 3
3
1 2
2 3
3 2
Output
3 1
Input
5
2 8 0 6 0
6
1 4
1 3
2 4
3 4
4 5
5 1
Output
8 2
Input
10
1 3 2 2 1 3 1 4 10 10
12
1 2
2 3
3 1
3 4
4 5
5 6
5 7
6 4
7 3
8 9
9 10
10 9
Output
15 6
Input
2
7 91
2
1 2
2 1
Output
7 1
----------------------------------------------------------------------------------------------------
D. Match & Catch
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
apple
pepperoni
Output
2
Input
lover
driver
Output
1
Input
bidhan
roy
Output
-1
Input
testsetses
teeptes
Output
3
----------------------------------------------------------------------------------------------------
E. Police Patrol
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 6
1 2 3
Output
4
Input
5 5
-7 -6 -3 -1 1
Output
16
Input
1 369
0
Output
0
Input
11 2
-375 -108 1336 1453 1598 1892 2804 3732 4291 4588 4822
Output
18716
----------------------------------------------------------------------------------------------------
