Codeforces Round 552 (Div. 3)


A. Restoring Three Numbers
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 6 5 4
Output
2 1 3
Input
40 40 40 60
Output
20 20 20
Input
201 101 101 200
Output
1 100 100
----------------------------------------------------------------------------------------------------
B. Make Them Equal
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
2 1 1
Output
4
Input
3 2 2
Output
7
Input
1 100 1
Output
3
Input
30 20 10
Output
39
----------------------------------------------------------------------------------------------------
D. Walking Robot
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2 1
0 1 0 1 0
Output
5
Input
6 2 1
1 0 0 1 0 1
Output
3
----------------------------------------------------------------------------------------------------
E. Two Teams
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
2 4 5 3 1
Output
11111
Input
5 1
2 1 3 5 4
Output
22111
Input
7 1
7 2 1 3 5 4 6
Output
1121122
Input
5 1
2 4 5 3 1
Output
21112
----------------------------------------------------------------------------------------------------
F. Shovels Shop
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 4 5
2 5 4 2 6 3 1
2 1
6 5
2 1
3 1
Output
7
Input
9 4 8
6 8 5 1 8 1 1 2 1
9 2
8 4
5 3
9 7
Output
17
Input
5 1 4
2 5 7 4 6
5 4
Output
17
----------------------------------------------------------------------------------------------------
G. Minimum Possible LCM
time limit per test: 4 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
5
2 4 8 3 6
Output
1 2
Input
5
5 2 11 3 7
Output
2 4
Input
6
2 5 10 1 10 2
Output
1 4
----------------------------------------------------------------------------------------------------
