Codeforces Round 412 (rated, Div. 1, based on VK Cup 2017 Round 3)


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

Examples
Input
4
3 10 1 2
7 14 3 8
20 70 2 7
5 6 1 1
Output
4
10
0
-1
----------------------------------------------------------------------------------------------------
B. Dynamic Problem Scoring
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
5 15 40 70 115
50 45 40 30 15
Output
2
Input
3
55 80 10 -1 -1
15 -1 79 60 -1
42 -1 13 -1 -1
Output
3
Input
5
119 119 119 119 119
0 0 0 0 -1
20 65 12 73 77
78 112 22 23 11
1 78 60 111 62
Output
27
Input
4
-1 20 40 77 119
30 10 73 50 107
21 29 -1 64 98
117 65 -1 -1 -1
Output
-1
----------------------------------------------------------------------------------------------------
C. Prairie Partition
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
1 1 2 2 3 4 5 8
Output
2 
Input
6
1 1 1 2 2 2
Output
2 3 
Input
5
1 2 4 4 4
Output
-1
----------------------------------------------------------------------------------------------------
D. Perishable Roads
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2
3
Output
2
2
3
Input
6
2 9 9 6 6
7 1 9 10
9 2 5
4 10
8
Output
6
5
7
5
7
11
----------------------------------------------------------------------------------------------------
E. Blog Post Rating
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 0 2 2
Output
1
1
2
2
Input
7
2 -3 -2 5 0 -3 1
Output
1
0
-1
0
1
1
2
----------------------------------------------------------------------------------------------------
F. Test Data Generation
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 6 100000
Output
4
Input
6 21 100129
Output
154
Input
58 787788 50216
Output
46009
----------------------------------------------------------------------------------------------------
