CodeCraft-20 (Div. 2)


A. Grade Allocation
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
4 10
1 2 3 4
4 5
1 2 3 4
Output
10
5
----------------------------------------------------------------------------------------------------
B. String Modification
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
4
abab
6
qwerty
5
aaaaa
6
alaska
9
lfpbavjsm
1
p
Output
abab
1
ertyqw
3
aaaaa
1
aksala
6
avjsmbpfl
5
p
1
----------------------------------------------------------------------------------------------------
C. Primitive Primes
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2 2
1 1 2
2 1
Output
1
Input
2 2 999999937
2 1
3 1
Output
2
----------------------------------------------------------------------------------------------------
D. Nash Matrix
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 1 1 1
2 2 2 2
Output
VALID
XL
RX
Input
3
-1 -1 -1 -1 -1 -1
-1 -1 2 2 -1 -1
-1 -1 -1 -1 -1 -1
Output
VALID
RRD
UXD
ULL
----------------------------------------------------------------------------------------------------
E. Team Building
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 1 2
1 16 10 3
18
19
13
15
Output
44
Input
6 2 3
78 93 9 17 13 78
80 97
30 52
26 17
56 68
60 36
84 55
Output
377
Input
3 2 1
500 498 564
100002 3
422332 2
232323 1
Output
422899
----------------------------------------------------------------------------------------------------
F. Battalion Strength
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 2
2
1 2
2 1
Output
500000004
1
500000004
Input
4
1 2 3 4
4
1 5
2 5
3 5
4 5
Output
625000011
13
62500020
375000027
62500027
----------------------------------------------------------------------------------------------------
