Codeforces Round 585 (Div. 2)


A. Yellow Cards
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
3
5
1
8
Output
0 4
Input
3
1
6
7
25
Output
4 4
Input
6
4
9
10
89
Output
5 9
----------------------------------------------------------------------------------------------------
B. The Number of Products
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
5 -3 3 -1 1
Output
8 7
Input
10
4 2 -4 3 1 2 -4 3 2 3
Output
28 27
Input
5
-1 -2 -3 -4 -5
Output
9 6
----------------------------------------------------------------------------------------------------
C. Swap Letters
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
abab
aabb
Output
2
3 3
3 2
Input
1
a
b
Output
-1
Input
8
babbaabb
abababaa
Output
3
2 6
1 3
7 8
----------------------------------------------------------------------------------------------------
D. Ticket Game
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
0523
Output
Bicarp
Input
2
??
Output
Bicarp
Input
8
?054??0?
Output
Bicarp
Input
6
???00?
Output
Monocarp
----------------------------------------------------------------------------------------------------
E. Marbles
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
3 4 2 3 4 2 2
Output
3
Input
5
20 1 14 10 2
Output
0
Input
13
5 5 4 4 3 5 7 6 5 4 4 6 5
Output
21
----------------------------------------------------------------------------------------------------
F. Radio Stations
time limit per test: 7 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 4 4 2
1 3
2 3
1 4
1 2
3 4
1 4
1 2
3 4
Output
2 3
1 3 
Input
2 4 4 2
1 3
2 4
1 2
1 2
3 4
3 4
1 2
3 4
Output
-1
----------------------------------------------------------------------------------------------------
