Codeforces Round 542 [Alex Lopashev Thanks-Round] (Div. 2)


A. Be Positive
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
10 0 -7 2 6
Output
4
Input
7
0 0 1 -1 0 0 2
Output
0
----------------------------------------------------------------------------------------------------
B. Two Cakes
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 1 2 2 3 3
Output
9
Input
2
2 1 1 2
Output
5
Input
4
4 1 3 2 2 3 1 4
Output
17
----------------------------------------------------------------------------------------------------
C. Connect
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 1
5 5
00001
11111
00111
00110
00110
Output
10
Input
3
1 3
3 1
010
101
010
Output
8
----------------------------------------------------------------------------------------------------
D1. Toy Train (Simplified)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 7
2 4
5 1
2 3
3 4
4 1
5 3
3 5
Output
10 9 10 10 9 
Input
2 3
1 2
1 2
1 2
Output
5 6 
----------------------------------------------------------------------------------------------------
D2. Toy Train
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 7
2 4
5 1
2 3
3 4
4 1
5 3
3 5
Output
10 9 10 10 9 
Input
2 3
1 2
1 2
1 2
Output
5 6 
----------------------------------------------------------------------------------------------------
E. Wrong Answer
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
Output
4
6 -8 7 -42
Input
612
Output
7
30 -12 -99 123 -2 245 -300
----------------------------------------------------------------------------------------------------
