Rockethon 2014


A. Genetic Engineering
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
GTTAAAG
Output
1
Input
AACCAACCAAAAC
Output
5
----------------------------------------------------------------------------------------------------
B. Word Folding
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
ABRACADABRA
Output
3
Input
ABBBCBDB
Output
3
Input
AB
Output
1
----------------------------------------------------------------------------------------------------
C1. The Tournament
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
1 1
1 4
2 2
Output
3
Input
2 1
3 2
4 0
Output
-1
Input
5 2
2 10
2 10
1 1
3 1
3 1
Output
12
----------------------------------------------------------------------------------------------------
C2. The Tournament
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
1 1
1 4
2 2
Output
3
Input
2 1
3 2
4 0
Output
-1
Input
5 2
2 10
2 10
1 1
3 1
3 1
Output
12
----------------------------------------------------------------------------------------------------
C3. The Tournament
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
1 1
1 4
2 2
Output
3
Input
2 1
3 2
4 0
Output
-1
Input
5 2
2 10
2 10
1 1
3 1
3 1
Output
12
----------------------------------------------------------------------------------------------------
D1. Supercollider
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 2
4 0 9
1 1 8
1 2 7
Output
2
----------------------------------------------------------------------------------------------------
D2. Supercollider
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 2
4 0 9
1 1 8
1 2 7
Output
2
----------------------------------------------------------------------------------------------------
E1. Three Trees
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2 3
1 2
1 2
1 2
2 3
Output
56
Input
5 1 4
1 2
2 5
3 4
4 2
1 2
1 3
1 4
Output
151
----------------------------------------------------------------------------------------------------
E2. Three Trees
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2 3
1 2
1 2
1 2
2 3
Output
56
Input
5 1 4
1 2
2 5
3 4
4 2
1 2
1 3
1 4
Output
151
----------------------------------------------------------------------------------------------------
F1. Stock Trading
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 2
2
7
3
9
8
7
9
7
1
9
Output
15
Input
10 5
2
7
3
9
8
7
9
7
1
9
Output
21
----------------------------------------------------------------------------------------------------
F2. Stock Trading
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 2
2
7
3
9
8
7
9
7
1
9
Output
15
Input
10 5
2
7
3
9
8
7
9
7
1
9
Output
21
----------------------------------------------------------------------------------------------------
F3. Stock Trading
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 2
2
7
3
9
8
7
9
7
1
9
Output
15
Input
10 5
2
7
3
9
8
7
9
7
1
9
Output
21
----------------------------------------------------------------------------------------------------
