Educational Codeforces Round 66 (Rated for Div. 2)


A. From Hero to Zero
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
59 3
1000000000000000000 10
Output
8
19
----------------------------------------------------------------------------------------------------
B. Catch Overflow!
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9
add
for 43
end
for 10
for 15
add
end
add
end
Output
161
Input
2
for 62
end
Output
0
Input
11
for 100
for 100
for 100
for 100
for 100
add
end
end
end
end
end
Output
OVERFLOW!!!
----------------------------------------------------------------------------------------------------
C. Electrification
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 2
1 2 5
2 1
1 1000000000
1 0
4
Output
3
500000000
4
----------------------------------------------------------------------------------------------------
D. Array Splitting
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
-1 -2 5 -4 8
Output
15
Input
7 6
-3 0 -1 -2 -2 -4 -1
Output
-45
Input
4 1
3 -1 6 0
Output
8
----------------------------------------------------------------------------------------------------
E. Minimal Segment Cover
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 3
1 3
2 4
1 3
1 4
3 4
Output
1
2
1
Input
3 4
1 3
1 3
4 5
1 2
1 3
1 4
1 5
Output
1
1
-1
-1
----------------------------------------------------------------------------------------------------
F. The Number of Subpermutations
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
2 4 1 3 4 2 1 2
Output
7
Input
5
1 1 2 1 2
Output
6
----------------------------------------------------------------------------------------------------
G. Yet Another Partiton Problem
time limit per test: 5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4 2
6 1 7 4
Output
25
Input
4 3
6 1 7 4
Output
21
Input
5 4
5 1 5 1 5
Output
21
----------------------------------------------------------------------------------------------------
