Is it a sequence?
InterviewTime limit1sMemory limit1024 MB
Given an array, check whether rearranging only the elements from index L to R can make the whole array non-decreasing.
- Level
Easy3 of 10
- Topics
- Array, Implementation
- Solved
- No attempts yet
Problem
An integer sequence of length is given. If the following condition holds, is a non-decreasing sequence.
- for every pair with
Check whether can become a non-decreasing sequence after rearranging the elements from the -th to the -th in any order.
Input
The first line contains , , and , separated by spaces.
The second line contains , separated by spaces.
Output
Print 1 if can be turned into a non-decreasing sequence, and 0 if it cannot.