ULTREVEN - Ultra-even
An array is 'ultra even' if the sum of every subarray of the array is even. Given an array of length n
, you are to determine whether a subarray is ultra even or not.
For example, the array [1, 4, 5, 2]
is not 'ultra even' because the subarray [4, 5]
has a sum of 9 which is not even (it also has other odd subarrays).
A subarray of an array is defined as some consecutive elements of the array (including of size one). For example, given the array [1, 4, 5, 2]
then [4, 5, 2]
is a subarray but [4, 2]
is not.
Input
Your first line will contain a single integer n
, representing the length of your given array.
Your next n
lines will contain n
space-separated integers, being the integers of the array in order.
1 ≤ n ≤ 10^5
Output
You should output YES if the array is 'ultra even', otherwise output NO.
Input 1 4 1 4 5 2 Output 1 NO
Input 2 3 2 4 6 Output 2 YES
Added by: | jslew |
Date: | 2021-11-05 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
Resource: | UMCPC Championships |