

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
長さ の非負整数列 が与えられます。
の異なる 要素の和として表せる値の中に偶数が存在するか判定し、存在する場合その最大値を求めてください。
制約
- の要素は相異なる
- 入力は全て整数
入力
入力は以下の形式で標準入力から与えられる。
出力
の異なる 要素の和として表せる値の中に偶数が存在しない場合、-1
を出力せよ。
偶数が存在する場合、その最大値を出力せよ。
入力例 1Copy
3 2 3 4
出力例 1Copy
6
の異なる 要素の和として表せる値は です。この中に偶数は存在し、その最大値は です。
入力例 2Copy
2 1 0
出力例 2Copy
-1
の異なる 要素の和として表せる値は です。この中に偶数は存在しないので、 -1
を出力してください。
Score : points
Problem Statement
You are given a sequence of length consisting of non-negative integers.
Determine if there is an even number represented as the sum of two different elements of . If it exists, find the maximum such number.
Constraints
- The elements of are distinct.
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print -1
if there is no even number represented as the sum of two different elements of .
If such an even number exists, print the maximum such number.
Sample Input 1Copy
3 2 3 4
Sample Output 1Copy
6
The values represented as the sum of two distinct elements of are , , and . We have an even number here, and the maximum is .
Sample Input 2Copy
2 1 0
Sample Output 2Copy
-1
The value represented as the sum of two distinct elements of is . We have no even number here, so -1
should be printed.