Testing Round 9


A. Second-Price Auction
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
5 7
Output
2 5
Input
3
10 2 8
Output
1 8
Input
6
3 8 2 9 4 14
Output
6 9
----------------------------------------------------------------------------------------------------
B. Fly, freebies, fly!
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
4 1 7 8 3 8
1
Output
3
----------------------------------------------------------------------------------------------------
C. Diverse Substrings
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
abca
Output
3
4
3
3
Input
aabacaabbad
Output
4
14
19
28
5
----------------------------------------------------------------------------------------------------
D. Game with Points
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 3 4
*aba
a*ab
ba*b
abb*
Output
1
4 1
Input
4
2 3 4
*abc
a*ab
ba*b
cbb*
Output
-1
----------------------------------------------------------------------------------------------------
