Educational Codeforces Round 28


A. Curriculum Vitae
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 1 0 1
Output
3
Input
6
0 1 0 0 1 0
Output
4
Input
1
0
Output
1
----------------------------------------------------------------------------------------------------
B. Math Show
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4 11
1 2 3 4
Output
6
Input
5 5 10
1 2 4 8 16
Output
7
----------------------------------------------------------------------------------------------------
C. Four Segments
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
-1 2 3
Output
0 1 3
Input
4
0 0 -1 0
Output
0 0 0
Input
1
10000
Output
1 1 1
----------------------------------------------------------------------------------------------------
D. Monitor
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 3 2 5
2 1 8
2 2 8
1 2 1
1 3 4
2 3 2
Output
8
Input
3 3 2 5
1 2 2
2 2 1
2 3 5
3 2 10
2 1 100
Output
-1
----------------------------------------------------------------------------------------------------
E. Chemistry in Berland
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 2 1
1 1
1 1
Output
YES
Input
3
3 2 1
1 2 3
1 1
1 2
Output
NO
----------------------------------------------------------------------------------------------------
F. Random Query
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 2
Output
1.500000
Input
2
2 2
Output
1.000000
----------------------------------------------------------------------------------------------------
