#K90647. Split Array into Strictly Increasing Odd and Even Subsequences

    ID: 37799 Type: Default 1000ms 256MiB

Split Array into Strictly Increasing Odd and Even Subsequences

Split Array into Strictly Increasing Odd and Even Subsequences

You are given an array of integers. Your task is to determine if the array can be split into two non-empty subsequences:

  • The first subsequence contains only odd numbers and is strictly increasing (each element is greater than its previous one).
  • The second subsequence contains only even numbers and is strictly increasing.

The order of the numbers in each subsequence is the same as their order in the original array. If both conditions are satisfied, output YES; otherwise, output NO.

Note: A subsequence is formed by deleting some or no elements without changing the order of the remaining elements. In this problem, you must use the original order of appearance.

inputFormat

The first line contains an integer n (the number of elements in the array). The second line contains n space-separated integers representing the array elements.

Example: 5
1 2 3 4 5

outputFormat

Output a single line: YES if the array can be split into two non-empty strictly increasing subsequences (one of odd numbers and one of even numbers), or NO otherwise.

## sample
5
1 2 3 4 5
YES

</p>