Is it a Heap?
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
The Heap data structure can be implement using an array.
The array must maintain the main heap property: for each next conditions must hold:
If , then
If , then
The array of integers is given. Determine whether it is a heap.
Input
First line contains number . Second line contains integers that do not exceed by absolute value.
Output
Print "YES", if the array is a heap and "NO" otherwise.
Examples
Input #1
Answer #1
Submissions 3K
Acceptance rate 33%