atcoder#ABC281D. [ABC281D] Max Multiple
[ABC281D] Max Multiple
Score : points
Problem Statement
You are given a sequence of non-negative integers .
Let be the set of non-negative integers that can be the sum of terms in (with distinct indices).
Find the greatest multiple of in . If there is no multiple of in , print -1
instead.
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
4 2 2
1 2 3 4
6
Here are all the ways to choose two terms in .
- Choose and , whose sum is .
- Choose and , whose sum is .
- Choose and , whose sum is .
- Choose and , whose sum is .
- Choose and , whose sum is .
- Choose and , whose sum is .
Thus, we have . The greatest multiple of in is , so you should print .
3 1 2
1 3 5
-1
In this example, we have . Nothing in is a multiple of , so you should print -1
.