COMPFEST 15 - Preliminary Online Mirror (Unrated, ICPC Rules, Teams Preferred)


A. Ambitious Kid
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 -6 5
Output
2
Input
1
-3
Output
3
Input
5
0 -1 0 1 0
Output
0
----------------------------------------------------------------------------------------------------
B. Battling with Numbers
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 3 5 7
2 1 1 2
2
3 7
1 1
Output
8
Input
2
1299721 1999993
100000 265
2
1299721 1999993
100000 265
Output
1
Input
2
2 5
1 1
2
2 3
1 1
Output
0
----------------------------------------------------------------------------------------------------
C. Completely Searching for Inversions
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
2
4 0
3 1
0
1
2 0
2
3 1
5 1
0
Output
4
----------------------------------------------------------------------------------------------------
D. Digital Wallet
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 3 1
10 4 2
8 1 9
4 8 2
Output
27
Input
3 3 2
5 9 4
1 3 1
2 8 7
Output
17
Input
3 4 3
5 9 10 1
1 3 1 5
2 5 7 2
Output
19
----------------------------------------------------------------------------------------------------
E. Elevators of Tamem
time limit per test: 5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
9 8
3 4 4 3 4 2 7 6
1 2 7
1 3 9
2 2
1 4 5
1 3 5
2 2
1 7 3
1 2 1
Output
114
----------------------------------------------------------------------------------------------------
F. Freak Joker Process
time limit per test: 5 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
5
3 3 1 3 2
3 7 1 3 1
8
3 1
3 2
2 4 +
1 2 -
3 2
3 3
2 2 -
3 1
Output
2
1
2
5
2
----------------------------------------------------------------------------------------------------
G. Grouped Carriages
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
7
7 4 2 0 5 8 3
4 0 0 1 3 1 3
Output
5
----------------------------------------------------------------------------------------------------
H. Happy Sets
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2
Output
11
Input
1 3
Output
8
Input
3 1
Output
4
----------------------------------------------------------------------------------------------------
I. Imagination Castle
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4 5 3
1 3
4 4
1 5
Output
Chaneka
Input
2 2 0
Output
Bhinneka
----------------------------------------------------------------------------------------------------
J. Jackets and Packets
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
8 7 2
4 4 2 4 1 2 2 1
Output
38
----------------------------------------------------------------------------------------------------
K. Keen Tree Calculation
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
7
5 1 2
1 4 2
3 4 1
2 5 3
6 1 6
4 7 2
2
4 3
3 2
Output
18
11
Input
3
1 2 1000000000
2 3 1000000000
1
2 1000000000
Output
2000000000000000000
----------------------------------------------------------------------------------------------------
L. Lihmuf Balling
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 1
Output
1
Input
5 4
Output
3
----------------------------------------------------------------------------------------------------
M. Mighty Rock Tower
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
80 50
Output
499122186
Input
3
25 16 20
Output
879786027
----------------------------------------------------------------------------------------------------
