Max Even

AtCoder
IDabc272_c
Time2000ms
Memory256MB
Difficulty
You are given a sequence $A=(A_1,A_2,\ldots,A_N)$ of length $N$ consisting of non-negative integers. Determine if there is an even number represented as the sum of two different elements of $A$. If it exists, find the maximum such number. ## Constraints * $2\leq N \leq 2\times 10^5$ * $0\leq A_i\leq 10^9$ * The elements of $A$ are distinct. * All values in the input are integers. ## Input The input is given from Standard Input in the following format: $N$ $A_1$ $A_2$ $\ldots$ $A_N$ [samples]
Samples
Input #1
3
2 3 4
Output #1
6

The values represented as the sum of two distinct elements of $A$ are $5$, $6$, and $7$. We have an even number here, and the maximum is $6$.
Input #2
2
1 0
Output #2
\-1

The value represented as the sum of two distinct elements of $A$ is $1$. We have no even number here, so `-1` should be printed.
API Response (JSON)
{
  "problem": {
    "name": "Max Even",
    "description": {
      "content": "You are given a sequence $A=(A_1,A_2,\\ldots,A_N)$ of length $N$ consisting of non-negative integers. Determine if there is an even number represented as the sum of two different elements of $A$. If it",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc272_c"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given a sequence $A=(A_1,A_2,\\ldots,A_N)$ of length $N$ consisting of non-negative integers.\nDetermine if there is an even number represented as the sum of two different elements of $A$. If it...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments