#CCBOTPBA0000021. Hiệu tổng chẵn lẻ (Even Sum Minus Odd Sum)
Hiệu tổng chẵn lẻ (Even Sum Minus Odd Sum)
Even Sum Minus Odd Sum
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given n signed integers, compute the sum of even values minus the sum of odd values, retaining signs. Empty sums are zero.
Input
n then exactly n integers.
Output
One 64-bit integer even_sum - odd_sum.
Subtasks
-
Subtask 1 (20%):
n ≤ 20;|a_i| ≤ 100. -
Subtask 2 (30%):
n ≤ 1000;|a_i| ≤ 10^6. -
Subtask 3 (50%):
n ≤ 100000;|a_i| ≤ 10^9.
Examples
Example 1
Input:
5
-2 -3 0 4 5
Output:
0
Explanation: Even values total two and odd values total two; their difference is zero.
Example 2
Input:
0
Output:
0
Explanation: Both sums are empty and therefore zero.