report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Good subarray - MarisaOJ: Marisa Online Judge

Good subarray

Time limit: 1000 ms
Memory limit: 256 MB
An array is called good if the elements form a consecutive integers array if sorted. Given an array $A$ of $n$ integers and $q$ queries of the form $(l, r)$, determine if subarray $A[l...r]$ is a good subarray. ### Input - The first line contains two integers $n, q$. - The second line contains $n$ integers $A_i$. - The next $q$ lines, each line contains two integers $l, r$, a query. ### Output - For each query, print `YES` if the subarray is good, otherwise print `NO`. ### Constraints - $1 \le n, q \le 10^5$. - $1 \le A_i \le n$. - $1 \le l \le r \le n$. ### Example Input: ``` 5 4 1 2 5 3 4 1 3 2 5 1 4 3 3 ``` Output: ``` NO YES NO YES ```
Hash a set
Prefix equality
Good subarray
Brewing potion 6
Mino
Traffic system
Odd
Topic
Data structure
Hashing
Rating 1600
Solution (1) Solution