Under construction

Still being built. Things may change

Is it a sequence?

Interview

Time limit1sMemory limit1024 MB

Summary
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 AA of length NN is given. If the following condition holds, AA is a non-decreasing sequence.

  • Ai≤AjA_i \le A_j for every pair (i,j)(i, j) with 1≤i<j≤N1 \le i < j \le N

Check whether AA can become a non-decreasing sequence after rearranging the elements from the LL-th to the RR-th in any order.

Input

The first line contains NN, LL, and RR, separated by spaces.

The second line contains A1,A2,A3,⋯ ,ANA_1, A_2, A_3, \cdots, A_N, separated by spaces.

Output

Print 1 if AA can be turned into a non-decreasing sequence, and 0 if it cannot.

Constraints

  • 1≤N≤100 0001 \le N \le 100\,000
  • 1≤L≤R≤N1 \le L \le R \le N
  • 1≤Ai≤1091 \le A_i \le 10^9

Examples2

  1. Example 1

    Input
    5 2 4
    1 4 2 3 5
    
    Expected output
    1
    
  2. Example 2

    Input
    5 2 4
    1 6 3 8 3
    
    Expected output
    0