Codeforces Round 228 (Div. 1)


A. Fox and Box Accumulation
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
0 0 10
Output
2
Input
5
0 1 2 3 4
Output
1
Input
4
0 0 0 0
Output
4
Input
9
0 1 0 2 0 1 1 2 10
Output
3
----------------------------------------------------------------------------------------------------
B. Fox and Minimal path
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
Output
4
NNYY
NNYY
YYNN
YYNN
Input
9
Output
8
NNYYYNNN
NNNNNYYY
YNNNNYYY
YNNNNYYY
YNNNNYYY
NYYYYNNN
NYYYYNNN
NYYYYNNN
Input
1
Output
2
NY
YN
----------------------------------------------------------------------------------------------------
C. Fox and Card Game
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 100
2 1 10
Output
101 10
Input
1
9 2 8 6 5 9 4 7 1 3
Output
30 15
Input
3
3 1 3 2
3 5 4 6
2 8 7
Output
18 18
Input
3
3 1000 1000 1000
6 1000 1000 1000 1000 1000 1000
5 1000 1000 1000 1000 1000
Output
7000 7000
----------------------------------------------------------------------------------------------------
D. Fox and Perfect Sets
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
Output
2
Input
2
Output
3
Input
3
Output
5
Input
4
Output
6
----------------------------------------------------------------------------------------------------
E. Fox and Meteor Shower
time limit per test: 6 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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