CodeTON Round 6 (Div. 1 + Div. 2, Rated, Prizes!)


A. MEXanized Array
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9
5 3 3
4 7 5
4 2 28
12 10 6
57 51 122
200 1 200
2 2 1
3 2 1
4 7 10
Output
7
-1
57
-1
2007
39800
1
2
-1
----------------------------------------------------------------------------------------------------
B. Friendly Arrays
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
2 3
0 1
1 2 3
3 1
1 1 2
1
Output
0 1
2 3
----------------------------------------------------------------------------------------------------
C. Colorful Table
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2 1
1 1
2 2
1 2
3 5
3 2 4
4 2
1 2 1 2
5 3
1 2 3 2 1
Output
4 
4 2 
0 6 6 2 0 
8 6 
10 6 2 
----------------------------------------------------------------------------------------------------
D. Prefix Purchase
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3
1 2 3
5
2
3 4
7
3
3 2 1
2
6
10 6 4 6 3 4
7
Output
5 0 0 
2 1 
2 2 2 
2 2 2 2 2 1 
----------------------------------------------------------------------------------------------------
E. Another MEX Problem
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2
1 0
10
1 2 0 7 1 2 0 2 4 3
10
2 1 0 7 1 2 0 2 4 3
3
1 2 1
Output
2
6
7
0
----------------------------------------------------------------------------------------------------
F. Lazy Numbers
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
2 2
4 2
6 4
33 2
532 13
780011804570805480 3788
366364720306464627 4702032149561577
293940402103595405 2
Output
2
2
1
3
1
3789
1
7
----------------------------------------------------------------------------------------------------
G. MEXanization
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
8
179 57 2 0 2 3 2 3
1
0
3
1 0 3
8
1 0 1 2 4 3 0 2
Output
179 2 3 3 3 4 4 5 
1 
1 2 2 
1 2 2 3 3 5 5 5 
----------------------------------------------------------------------------------------------------
H. Standard Graph Problem
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4 5 6
1 2 1
2 3 5
3 2 3
4 1 8
2 1 4
+ 1
- 1
+ 3
+ 1
+ 4
+ 2
Output
15
-1
14
12
4
0
Input
10 14 10
8 6 4
2 5 1
3 5 4
1 6 3
1 3 7
7 2 1
6 1 3
4 10 1
4 6 5
5 4 1
5 8 10
10 9 1
9 5 1
9 7 6
+ 7
+ 8
- 7
+ 10
+ 2
- 10
+ 5
- 2
- 5
+ 3
Output
28
24
29
19
18
24
18
19
29
20
----------------------------------------------------------------------------------------------------
