Largest even number
Xem dạng PDF
Gửi bài giải
Điểm:
1,00
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
256M
Input:
stdin
Output:
stdout
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch, TEXT
Largest Even Number in an Array
Given an array of n integers, find the largest even number in the array.
Input
The first line contains an integer n, the number of elements in the array.
n <= 10^5
The second line contains n integers a_i.
|a_i| <= 10^9
Output
Output the largest even number in the array.
If the array contains no even number, output -1.
Example 1
Input
5
1 2 -3 -4 6
Output
6
Example 2
Input
3
1 3 5
Output
-1
Bình luận