You've got an array, consisting of n integers a_1, a_2, ..., a_{n}. Also, you've got m queries, the i-th query is described by two integers l_{i}, r_{i}. Numbers l_{i}, r_{i} define a subsegment of the original array, that is, the sequence of numbers a_{l}_{i}, a_{l}_{i} + 1, a_{l}_{i} + 2, ..., a_{r}_{i}. For each query you should check whether the corresponding segment is a ladder. 

A ladder is a sequence of integers b_1, b_2, ..., b_{k}, such that it first doesn't decrease, then doesn't increase. In other words, there is such integer x (1 ≤ x ≤ k), that the following inequation fulfills: b_1 ≤ b_2 ≤ ... ≤ b_{x} ≥ b_{x} + 1 ≥ b_{x} + 2... ≥ b_{k}. Note that the non-decreasing and the non-increasing sequences are also considered ladders.


-----Input-----

The first line contains two integers n and m (1 ≤ n, m ≤ 10^5) — the number of array elements and the number of queries. The second line contains the sequence of integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^9), where number a_{i} stands for the i-th array element.

The following m lines contain the description of the queries. The i-th line contains the description of the i-th query, consisting of two integers l_{i}, r_{i} (1 ≤ l_{i} ≤ r_{i} ≤ n) — the boundaries of the subsegment of the initial array.

The numbers in the lines are separated by single spaces.


-----Output-----

Print m lines, in the i-th line print word "Yes" (without the quotes), if the subsegment that corresponds to the i-th query is the ladder, or word "No" (without the quotes) otherwise. 


-----Examples-----
Input
8 6
1 2 1 3 3 5 2 1
1 3
2 3
2 4
8 8
1 4
5 8

Output
Yes
Yes
No
Yes
No
Yes

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Dynamic programming

Amortized analysis

Implementation


Solutions:
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
l1 = [0] * n
l2 = [0] * n
(c1, c2) = (0, 0)
for i in range(1, n - 1):
	if l[i] < l[i + 1] and l[i] < l[i - 1]:
		c1 += 1
	if l[i] == l[i - 1] and l[i] < l[i + 1]:
		c2 += 1
	if l[i] == l[i + 1] and l[i] < l[i - 1]:
		c2 += 1
	l1[i] = c1
	l2[i] = c2
l1[n - 1] = c1
l2[n - 1] = c2
for i in range(m):
	(x, y) = map(int, input().split())
	if y - x <= 1:
		print('Yes')
	elif y - x == 2:
		if l[y - 1] > l[y - 2] and l[x - 1] > l[y - 2]:
			print('No')
		else:
			print('Yes')
	elif l1[y - 2] - l1[x - 1] > 0 or l2[y - 2] - l2[x - 1] > 1:
		print('No')
	else:
		print('Yes')


import sys
(n, m) = list(map(int, sys.stdin.readline().split()))
M = [m]
A = list(map(int, sys.stdin.readline().split()))
L = [0] * n
inc = False
dec = False

def ALLYes():
	Ans = ''
	for i in range(M[0]):
		Ans += 'Yes\n'
	sys.stdout.write(Ans)
	return
for i in range(1, n):
	if A[i] > A[i - 1]:
		L[i] = 1
		inc = True
	elif A[i] == A[i - 1]:
		L[i] = 0
	else:
		L[i] = -1
		dec = True
if inc == False or dec == False:
	ALLYes()
else:
	neg = L.index(-1)
	pos = L.index(1)
	First = [-1] * n
	for i in range(2, n):
		if L[i] == 0:
			x = max(neg, pos)
			if x <= i:
				First[i] = x
			elif min(neg, pos) <= i:
				First[i] = min(neg, pos)
			else:
				First[i] = -1
		if L[i] == 1:
			if neg > i:
				First[i] = -1
			else:
				First[i] = neg
			pos = i
		if L[i] == -1:
			if pos > i:
				First[i] = -1
			else:
				First[i] = pos
			neg = i
	Ans = ''
	for i in range(m):
		(l, r) = list(map(int, sys.stdin.readline().split()))
		r -= 1
		if r - l < 1:
			Ans += 'Yes\n'
			continue
		if L[r] == 0:
			r = First[r]
			if r < 1:
				Ans += 'Yes\n'
				continue
		if L[r] == 1:
			r = First[r]
			if r < l:
				Ans += 'Yes\n'
				continue
			else:
				Ans += 'No\n'
				continue
		elif L[r] == -1:
			r = First[r]
			if r < l:
				Ans += 'Yes\n'
				continue
			r = First[r]
			if r < l:
				Ans += 'Yes\n'
				continue
			else:
				Ans += 'No\n'
				continue
	sys.stdout.write(Ans)


import sys
input = sys.stdin.readline
(a, b) = map(int, input().split())
z = list(map(int, input().split()))
ans = [0]
for i in range(1, len(z)):
	if z[i] > z[i - 1]:
		ans.append(1)
	elif z[i] < z[i - 1]:
		ans.append(2)
	else:
		ans.append(0)
start = [0 for i in range(len(ans))]
for i in range(len(ans) - 1, -1, -1):
	if ans[i] == 2:
		start[i] = i
	elif i == len(ans) - 1:
		start[i] = -1
	else:
		start[i] = start[i + 1]
end = [0 for i in range(len(ans))]
for i in range(len(ans)):
	if ans[i] == 1:
		end[i] = i
	elif i == 0:
		end[i] = -1
	else:
		end[i] = end[i - 1]
for i in range(b):
	(l, r) = map(int, input().split())
	if l == len(z):
		print('Yes')
		continue
	if start[l] == -1 or end[r - 1] == -1:
		print('Yes')
	elif start[l] > end[r - 1]:
		print('Yes')
	else:
		print('No')


import sys
import heapq
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
print = sys.stdout.write
sys.setrecursionlimit(100000)

def PRINT(lst, sep=' '):
	print(sep.join(map(str, lst)))
I = lambda : list(map(int, input().split(' ')))

def solve(lst, queries):
	n = len(lst)
	arr_f = [1]
	cur_max = 1
	for i in range(n - 2, -1, -1):
		if lst[i] <= lst[i + 1]:
			cur_max += 1
		else:
			cur_max = 1
		arr_f.append(cur_max)
	arr_f.reverse()
	arr_b = [1]
	cur_max = 1
	for i in range(n - 1):
		if lst[i + 1] <= lst[i]:
			cur_max += 1
		else:
			cur_max = 1
		arr_b.append(cur_max)
	ans = []
	for (l, r) in queries:
		l = l - 1
		r = r - 1
		if arr_f[l] + arr_b[r] >= r - l + 1:
			ans.append('Yes')
		else:
			ans.append('No')
	PRINT(ans, sep='\n')
(n, m) = I()
lst = I()
queries = [I() for i in range(m)]
solve(lst, queries)


def main():
	from sys import stdin, stdout
	(n, m) = map(int, stdin.readline().strip().split(' '))
	a = [0] + list(map(int, stdin.readline().strip().split(' ')))
	r = [0] * (n + 1)
	l = [0] * (n + 1)
	l[1] = 1
	r[n] = n
	for i in range(2, n + 1):
		if a[i - 1] >= a[i]:
			l[i] = l[i - 1]
		else:
			l[i] = i
	for i in range(n - 1, 0, -1):
		if a[i + 1] >= a[i]:
			r[i] = r[i + 1]
		else:
			r[i] = i
	for i in range(m):
		(a, b) = map(int, stdin.readline().strip().split(' '))
		if r[a] >= l[b]:
			stdout.write('Yes\n')
		else:
			stdout.write('No\n')
main()


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def search(a, t):
	l = 0
	r = len(a) - 1
	ans = -1
	while r - l >= 0:
		mid = (l + r) // 2
		if a[mid][0] <= t:
			l = mid + 1
			ans = mid
		if a[mid][0] > t:
			r = mid - 1
	return ans
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ladders = []
cur = 0
inc = True
for i in range(1, n):
	if inc:
		if a[i] < a[i - 1]:
			inc = False
	elif a[i] > a[i - 1]:
		j = i - 1
		while j >= 0 and a[j] == a[i - 1]:
			j -= 1
		ladders.append((cur, i - 1))
		cur = j + 1
		inc = True
ladders.append((cur, n - 1))
ladders.sort()
for i in range(m):
	(l, r) = map(int, input().split())
	ind = search(ladders, l - 1)
	if ladders[ind][1] >= r - 1:
		print('Yes')
	else:
		print('No')


(n, m) = list(map(int, input().split()))
arr = list(map(int, input().split()))
up = [i for i in range(n)]
down = [i for i in range(n)]
for i in range(1, n):
	if arr[i - 1] <= arr[i]:
		up[i] = up[i - 1]
	if arr[i - 1] >= arr[i]:
		down[i] = down[i - 1]
all_res = []
seg = list(tuple((list(map(int, input().split())) for _ in range(m))))
for (l, r) in seg:
	if l - 1 >= up[down[r - 1]]:
		all_res.append('Yes')
	else:
		all_res.append('No')
print('\n'.join(all_res))


from __future__ import division, print_function
import math
import os
import sys
from fractions import *
from sys import *
from io import BytesIO, IOBase
from itertools import *
from collections import *
M = 10 ** 9 + 7
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def inpu():
	return int(inp())

def regularbracket(t):
	p = 0
	for i in t:
		if i == '(':
			p += 1
		else:
			p -= 1
		if p < 0:
			return False
	else:
		if p > 0:
			return False
		else:
			return True

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def reverse1(string):
	pp = ''
	for i in string[::-1]:
		pp += i
	if pp == string:
		return True
	return False

def reverse2(list1):
	l = []
	for i in list1[::-1]:
		l.append(i)
	if l == list1:
		return True
	return False

def mex(list1):
	p = max(list1) + 1
	for i in range(len(list1)):
		if list1[i] != i:
			p = i
			break
	return p

def sumofdigits(n):
	n = str(n)
	s1 = 0
	for i in n:
		s1 += int(i)
	return s1

def perfect_square(n):
	s = math.sqrt(n)
	if s == int(s):
		return True
	return False

def roman_number(x):
	if x > 15999:
		return
	value = [5000, 4000, 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
	symbol = ['F', 'MF', 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
	roman = ''
	i = 0
	while x > 0:
		div = x // value[i]
		x = x % value[i]
		while div:
			roman += symbol[i]
			div -= 1
		i += 1
	return roman

def soretd(s):
	for i in range(1, len(s)):
		if s[i - 1] > s[i]:
			return False
	return True

def countRhombi(h, w):
	ct = 0
	for i in range(2, h + 1, 2):
		for j in range(2, w + 1, 2):
			ct += (h - i + 1) * (w - j + 1)
	return ct

def countrhombi2(h, w):
	return h * h // 4 * (w * w // 4)

def binpow(a, b):
	if b == 0:
		return 1
	else:
		res = binpow(a, b // 2)
	if b % 2 != 0:
		return res * res * a
	else:
		return res * res

def binpowmodulus(a, b, m):
	a %= m
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a = a * a % m
		b >>= 1
	return res

def coprime_to_n(n):
	result = n
	i = 2
	while i * i <= n:
		if n % i == 0:
			while n % i == 0:
				n //= i
			result -= result // i
		i += 1
	if n > 1:
		result -= result // n
	return result

def prime(x):
	if x == 1:
		return False
	else:
		for i in range(2, int(math.sqrt(x)) + 1):
			if x % i == 0:
				return False
		else:
			return True

def luckynumwithequalnumberoffourandseven(x, n, a):
	if x >= n and str(x).count('4') == str(x).count('7'):
		a.append(x)
	elif x < 1000000000000.0:
		luckynumwithequalnumberoffourandseven(x * 10 + 4, n, a)
		luckynumwithequalnumberoffourandseven(x * 10 + 7, n, a)
	return a

def luckynuber(x, n, a):
	p = set(str(x))
	if len(p) <= 2:
		a.append(x)
	if x < n:
		luckynuber(x + 1, n, a)
	return a

def interact(type, x):
	if type == 'r':
		inp = input()
		return inp.strip()
	else:
		print(x, flush=True)

def findTrailingZeros(n):
	count = 0
	while n >= 5:
		n //= 5
		count += n
	return count

def mergeSort(arr):
	if len(arr) > 1:
		mid = len(arr) // 2
		L = arr[:mid]
		R = arr[mid:]
		mergeSort(L)
		mergeSort(R)
		i = j = k = 0
		while i < len(L) and j < len(R):
			if L[i] < R[j]:
				arr[k] = L[i]
				i += 1
			else:
				arr[k] = R[j]
				j += 1
			k += 1
		while i < len(L):
			arr[k] = L[i]
			i += 1
			k += 1
		while j < len(R):
			arr[k] = R[j]
			j += 1
			k += 1
res = set()

def solven(p, l, a, b, n):
	if p > n or l > 10:
		return
	if p > 0:
		res.add(p)
	solven(p * 10 + a, l + 1, a, b, n)
	solven(p * 10 + b, l + 1, a, b, n)

def subsetsUtil(A, subset, index, d):
	print(*subset)
	s = sum(subset)
	d.append(s)
	for i in range(index, len(A)):
		subset.append(A[i])
		subsetsUtil(A, subset, i + 1, d)
		subset.pop(-1)
	return d

def subsetSums(arr, l, r, d, sum=0):
	if l > r:
		d.append(sum)
		return
	subsetSums(arr, l + 1, r, d, sum + arr[l])
	subsetSums(arr, l + 1, r, d, sum)
	return d

def print_factors(x):
	factors = []
	for i in range(1, x + 1):
		if x % i == 0:
			factors.append(i)
	return factors

def calc(X, d, ans, D):
	if len(X) == 0:
		return
	i = X.index(max(X))
	ans[D[max(X)]] = d
	Y = X[:i]
	Z = X[i + 1:]
	calc(Y, d + 1, ans, D)
	calc(Z, d + 1, ans, D)

def factorization(n, l):
	c = n
	if prime(n) == True:
		l.append(n)
		return l
	for i in range(2, c):
		if n == 1:
			break
		while n % i == 0:
			l.append(i)
			n = n // i
	return l

def good(b):
	l = []
	i = 0
	while len(b) != 0:
		if b[i] < b[len(b) - 1 - i]:
			l.append(b[i])
			b.remove(b[i])
		else:
			l.append(b[len(b) - 1 - i])
			b.remove(b[len(b) - 1 - i])
	if l == sorted(l):
		return True
	return False

def generate(st, s):
	if len(s) == 0:
		return
	if s not in st:
		st.add(s)
		for i in range(len(s)):
			t = list(s).copy()
			t.remove(s[i])
			t = ''.join(t)
			generate(st, t)
	return

def largestincreasingsubsequence(A):
	l = [1] * len(A)
	sub = []
	for i in range(1, len(l)):
		for k in range(i):
			if A[k] < A[i]:
				sub.append(l[k])
		l[i] = 1 + max(sub, default=0)
	return max(l, default=0)

def main():
	(n, m) = sep()
	dp = [0] * (n + 1)
	ap = [0] * (n + 1)

	def fun(arr, n):
		for i in range(n - 1, 0, -1):
			if arr[i] >= arr[i + 1]:
				dp[i] = 1 + dp[i + 1]
		for i in range(n - 1, 0, -1):
			if arr[i] <= arr[i + 1]:
				ap[i] = 1 + ap[i + 1]
	arr = lis()
	arr.insert(0, 0)
	fun(arr, n)
	for _ in range(m):
		(u, v) = sep()
		x = u + ap[u] + dp[u + ap[u]]
		if x >= v:
			print('Yes')
		else:
			print('No')
main()


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase

def main():
	(n, m) = [int(x) for x in input().split()]
	array = [int(x) for x in input().split()]
	increasing = list(range(n))
	decreasing = list(range(n))
	for i in range(1, n):
		if array[i] >= array[i - 1]:
			increasing[i] = increasing[i - 1]
		if array[i] <= array[i - 1]:
			decreasing[i] = decreasing[i - 1]
	for query in range(m):
		(left, right) = [int(x) - 1 for x in input().split()]
		vertex = decreasing[right]
		limit = increasing[vertex]
		if left >= limit:
			print('Yes')
		else:
			print('No')
BUFFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
input = lambda : sys.stdin.readline().rstrip('\r\n')

def print(*args, **kwargs):
	sep = kwargs.pop('sep', ' ')
	file = kwargs.pop('file', sys.stdout)
	atStart = True
	for x in args:
		if not atStart:
			file.write(sep)
		file.write(str(x))
		atStart = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
main()


import sys
import math as mt
import bisect
input = sys.stdin.buffer.readline
t = 1
for __ in range(t):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	l.insert(0, 0)
	ri = [0] * (n + 1)
	ri[n] = n
	for i in range(n - 1, 0, -1):
		if l[i] <= l[i + 1]:
			ri[i] = ri[i + 1]
		else:
			ri[i] = i
	le = [0] * (n + 1)
	le[1] = 1
	for i in range(2, n + 1):
		if l[i - 1] >= l[i]:
			le[i] = le[i - 1]
		else:
			le[i] = i
	for j in range(m):
		(a, b) = map(int, input().split())
		if ri[a] >= le[b]:
			print('Yes')
		else:
			print('No')


import os
import sys
from io import BytesIO, IOBase
sys.setrecursionlimit(95000)

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()

def bs(q, x, l):
	(i, j) = (0, l)
	while i <= j:
		mid = (i + j) // 2
		if q[mid] == x:
			return mid
		elif q[mid] > x:
			j = mid - 1
		else:
			i = mid + 1
	return j

def inc(x, y, q, l):
	if l == 0 or (q[0] == 1 and q[1] == n):
		return 1
	if y - x <= 1:
		return 1
	else:
		ind = bs(q, x, l)
		if ind == -1:
			if y <= q[0]:
				return 1
			else:
				return 0
		elif ind % 2 == 0:
			if ind + 2 < l:
				if y >= q[ind] and y <= q[ind + 2]:
					return 1
				else:
					return 0
			elif y >= q[ind]:
				return 1
			else:
				return 0
		elif ind == l - 1:
			return 1
		elif y >= q[ind] and y <= q[ind + 1]:
			return 1
		else:
			return 0

def dec(x, y, q, l):
	if l == 0 or (q[0] == 1 and q[1] == n):
		return 1
	if y - x <= 1:
		return 1
	else:
		ind = bs(q, x, l)
		if ind == -1:
			if y <= q[1]:
				return 1
			else:
				return 0
		elif ind % 2 == 0:
			if y >= q[ind] and y <= q[ind + 1]:
				return 1
			else:
				return 0
		else:
			if ind == l - 1:
				return 1
			if ind + 2 < l:
				if y >= q[ind] + 1 and y <= q[ind + 2]:
					return 1
				else:
					return 0
			elif y >= q[ind]:
				return 1
			else:
				return 0
arr = [int(x) for x in input().split()]
(n, m) = (arr[0], arr[1])
arr = [int(x) for x in input().split()]
(q1, q2) = ([], [])
(start1, end1, start2, end2) = (-1, -1, -1, -1)
for i in range(1, n):
	if arr[i] >= arr[i - 1] and start1 == -1:
		start1 = i
		end1 = i + 1
	elif arr[i] >= arr[i - 1] and start1 != -1:
		end1 = i + 1
	elif arr[i] < arr[i - 1]:
		if start1 != -1:
			q1.append(start1)
			q1.append(end1)
			start1 = -1
			end1 = -1
	if arr[i] <= arr[i - 1] and start2 == -1:
		start2 = i
		end2 = i + 1
	elif arr[i] <= arr[i - 1] and start2 != -1:
		end2 = i + 1
	elif arr[i] > arr[i - 1]:
		if start2 != -1:
			q2.append(start2)
			q2.append(end2)
			start2 = -1
			end2 = -1
if end1 != -1 and start1 != -1:
	q1.append(start1)
	q1.append(end1)
if end2 != -1 and start2 != -1:
	q2.append(start2)
	q2.append(end2)
l1 = len(q1)
l2 = len(q2)
for i in range(m):
	li = [int(x) for x in input().split()]
	(x, y) = (li[0], li[1])
	if inc(x, y, q1, l1) or dec(x, y, q2, l2):
		print('Yes')
	else:
		print('No')


import traceback
import math
from collections import defaultdict
from functools import lru_cache

def main():
	(N, T) = map(int, input().split())
	a = list(map(int, input().split()))
	inc = [-1] * N
	dec = [-1] * N
	p = N - 1
	for i in range(N - 1, -1, -1):
		if i != N - 1 and a[i] > a[i + 1]:
			p = i
		inc[i] = p
	p = 0
	for i in range(N):
		if i != 0 and a[i] > a[i - 1]:
			p = i
		dec[i] = p

	def solve(l, r):
		return inc[l] >= dec[r]
	res = []
	for _ in range(T):
		(l, r) = list(map(int, input().split()))
		ans = solve(l - 1, r - 1)
		ans = 'Yes' if ans else 'No'
		res.append(ans)
	print('\n'.join(res))
try:
	ans = main()
except Exception as e:
	traceback.print_exc()


import sys, os, io
import math
from collections import defaultdict
from io import BytesIO, IOBase
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')

def solve():
	(n, q) = li()
	l = li()
	ltor = [1] * n
	rtol = [1] * n
	lplace = [i for i in range(n)]
	rplace = [i for i in range(n)]
	for i in range(1, n):
		if l[i] <= l[i - 1]:
			ltor[i] += ltor[i - 1]
			lplace[i] = lplace[i - 1]
	for i in range(n - 2, -1, -1):
		if l[i] <= l[i + 1]:
			rtol[i] += rtol[i + 1]
			rplace[i] = rplace[i + 1]
	leq = [1] * n
	req = [1] * n
	for i in range(1, n):
		if l[i] == l[i - 1]:
			leq[i] += leq[i - 1]
	for i in range(n - 2, -1, -1):
		if l[i] == l[i + 1]:
			req[i] += req[i + 1]
	for i in range(q):
		(left, right) = li()
		left -= 1
		right -= 1
		if rtol[left] + ltor[right] >= right - left + 1:
			print('Yes')
		else:
			print('No')
t = 1
for _ in range(t):
	solve()


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
(values, increase, decrease) = ([int(i) for i in input().split()], [0 for _ in range(n)], [0 for _ in range(n)])
for i in range(n - 2, -1, -1):
	if values[i] <= values[i + 1]:
		increase[i] = increase[i + 1] + 1
	else:
		increase[i] = 0
	if values[i] >= values[i + 1]:
		decrease[i] = decrease[i + 1] + 1
	else:
		decrease[i] = 0
for i in range(m):
	(a, b) = map(int, input().split())
	(a, b) = (a - 1, b - 1)
	if a + increase[a] >= b or a + decrease[a] >= b or a + increase[a] + decrease[a + increase[a]] >= b:
		print('Yes')
	else:
		print('No')


from sys import stdin
input = lambda : stdin.readline().strip()
from math import ceil, sqrt, factorial, gcd
from collections import deque
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
l = [0] + l
a = [0 for i in range(n + 1)]
a[-1] = n
b = list(a)
for i in range(n - 1, 0, -1):
	if l[i] <= l[i + 1]:
		a[i] = a[i + 1]
	else:
		a[i] = i
	if l[i] >= l[i + 1]:
		b[i] = b[i + 1]
	else:
		b[i] = i
for i in range(m):
	(x, y) = map(int, input().split())
	if b[a[x]] >= y:
		print('Yes')
	else:
		print('No')


import sys

def get_ints():
	return list(map(int, sys.stdin.readline().strip().split()))
(n, m) = get_ints()
a = get_ints()
d1 = [0] * n
d2 = [0] * n
for i in range(1, n - 1):
	if a[i] < a[i - 1] and a[i] < a[i + 1]:
		d1[i] = 1
	elif a[i] < a[i - 1] and a[i] == a[i + 1]:
		d2[i] = 1
	elif a[i] == a[i - 1] and a[i + 1] > a[i]:
		d2[i] = 1
for i in range(1, n):
	d1[i] = d1[i - 1] + d1[i]
	d2[i] = d2[i] + d2[i - 1]
d1 = [0] + d1
d2 = [0] + d2
for i in range(m):
	(l, r) = get_ints()
	if d1[r - 1] - d1[l] > 0 or d2[r - 1] - d2[l] > 1:
		print('No')
	else:
		print('Yes')


import sys
(n, m) = map(int, sys.stdin.readline().split())
L = list(map(int, sys.stdin.readline().split()))
R = [0] * n
K = [0] * n
p = 0
for i in range(1, n):
	if L[i] < L[i - 1]:
		for j in range(p, i):
			R[j] = i
		p = i
for j in range(p, n):
	R[j] = n
p = 0
for i in range(1, n):
	if L[i] > L[i - 1]:
		for j in range(p, i):
			K[j] = i
		p = i
for j in range(p, n):
	K[j] = n
for i in range(m):
	(x, y) = map(int, sys.stdin.readline().split())
	x -= 1
	y -= 1
	r = R[x]
	if r >= y:
		sys.stdout.write('Yes\n')
		continue
	e = K[r]
	if e > y:
		sys.stdout.write('Yes\n')
		continue
	sys.stdout.write('No\n')


from sys import stdin
from bisect import bisect_left
(n, m) = map(int, stdin.readline().split())
seq = list(map(int, stdin.readline().split()))
up = [0 for i in range(n + 1)]
dn = [0 for i in range(n + 1)]
for i in range(1, n):
	up[i] = up[i - 1]
	dn[i] = dn[i - 1]
	if seq[i - 1] < seq[i]:
		up[i] += 1
	elif seq[i - 1] > seq[i]:
		dn[i] += 1
up[n] = up[n - 1]
dn[n] = dn[n - 1]
for i in range(m):
	(l, r) = map(int, stdin.readline().split())
	l -= 1
	r -= 1
	if up[l] == up[r] or dn[l] == dn[r]:
		print('Yes')
		continue
	last_up = bisect_left(up, up[r], l, r)
	first_dn = bisect_left(dn, dn[l] + 1, l, r)
	print('Yes' if last_up < first_dn else 'No')


import sys

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
(n, m) = get_ints()
Arr = get_array()
up = [i for i in range(n)]
down = [i for i in range(n)]
for i in range(1, n):
	if Arr[i - 1] <= Arr[i]:
		up[i] = up[i - 1]
	if Arr[i - 1] >= Arr[i]:
		down[i] = down[i - 1]
while m:
	(l, r) = get_ints()
	if l - 1 >= up[down[r - 1]]:
		print('Yes')
	else:
		print('No')
	m -= 1


from sys import stdin
import sys
import copy
sys.setrecursionlimit(15000)

def create_dp(arr, n):
	dp1 = [-1] * n
	dp1[-1] = n - 1
	for i in range(n - 2, -1, -1):
		if arr[i] <= arr[i + 1]:
			dp1[i] = dp1[i + 1]
		else:
			dp1[i] = i
	dp2 = [-1] * n
	dp2[-1] = n - 1
	for i in range(n - 2, -1, -1):
		if arr[i] >= arr[i + 1]:
			dp2[i] = dp2[i + 1]
		else:
			dp2[i] = i
	return (dp1, dp2)
(n, m) = list(map(int, stdin.readline().split()))
arr = list(map(int, stdin.readline().split()))
(dp1, dp2) = create_dp(arr, n)
for _ in range(m):
	(l, r) = list(map(int, stdin.readline().split()))
	if dp2[dp1[l - 1]] >= r - 1:
		print('Yes')
	else:
		print('No')


import os, sys
from bisect import bisect_left
from collections import defaultdict, Counter, deque
from copy import deepcopy
from io import BytesIO, IOBase
from math import gcd
import math
import sys

def main():
	(n, m) = map(int, input().split())
	a = [int(X) for X in input().split()]
	x = 0
	z1 = [0, 0]
	z2 = [0, 0]
	for i in range(1, n - 1):
		if a[i - 1] > a[i] < a[i + 1]:
			z1.append(z1[-1] + 1)
		elif a[i - 1] > a[i] == a[i + 1]:
			z1.append(z1[-1] + 0.5)
		elif a[i - 1] == a[i] < a[i + 1]:
			z1.append(z1[-1] + 0.5)
		else:
			z1.append(z1[-1])
	z1.append(z1[-1])
	for j in range(m):
		(p, q) = map(int, input().split())
		if p == q:
			print('Yes')
		elif z1[q - 1] - z1[p] >= 1:
			print('No')
		else:
			print('Yes')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import os
import sys
from io import BytesIO, IOBase
import math

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
import os
import sys
from io import BytesIO, IOBase

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
ia = [0] * n
db = [0] * n
db[0] = 0
for i in range(1, n):
	if l[i] <= l[i - 1]:
		db[i] = db[i - 1]
	else:
		db[i] = i
ia[n - 1] = n - 1
for i in range(n - 2, -1, -1):
	if l[i] <= l[i + 1]:
		ia[i] = ia[i + 1]
	else:
		ia[i] = i
for i in range(m):
	(a, b) = map(int, input().split())
	a -= 1
	b -= 1
	if ia[a] >= db[b]:
		print('Yes')
	else:
		print('No')


import time, math as mt, bisect, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IO():
	return stdin.readline()

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def readTree():
	v = int(input())
	adj = [set() for i in range(v + 1)]
	for i in range(v - 1):
		(u1, u2) = In()
		adj[u1].add(u2)
		adj[u2].add(u1)
	return (adj, v)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * 1000001
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(1000001):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def SPF():
	spf[1] = 1
	for i in range(2, mx + 1):
		if spf[i] == mx:
			spf[i] = i
			for j in range(i * i, mx + 1, i):
				if i < spf[j]:
					spf[j] = i
	return
mod = 10 ** 9 + 7

def solve():
	(n, m) = IP()
	li = L()
	inc = [i for i in range(n)]
	dec = [i for i in range(n)]
	for i in range(1, n):
		if li[i] >= li[i - 1]:
			inc[i] = inc[i - 1]
		if li[i] <= li[i - 1]:
			dec[i] = dec[i - 1]
	for i in range(m):
		(l, r) = IP()
		if l - 1 >= inc[dec[r - 1]]:
			P('Yes')
		else:
			P('No')
solve()


[n, q] = list(map(int, input().split()))
arr = list(map(int, input().split()))
interval = [idx for idx in range(n)]
(l, r) = (0, 1)
while l <= r and r < n:
	while r < n and arr[r] >= arr[r - 1]:
		r += 1
	last = r
	while r < n and arr[r] <= arr[r - 1]:
		if arr[r] != arr[last]:
			last = r
		r += 1
	for idx in range(l, r):
		interval[idx] = max(interval[idx], r - 1)
	l = last
ans = []
for _ in range(q):
	[l, r] = list(map(int, input().split()))
	if interval[l - 1] >= r - 1:
		ans.append('Yes')
	else:
		ans.append('No')
for x in ans:
	print(x)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass
(n, m) = L()
dp = [0 for i in range(100100)]
ap = [0 for i in range(100100)]

def solve(ar):
	for i in range(n - 1, 0, -1):
		if ar[i] >= ar[i + 1]:
			dp[i] = dp[i + 1] + 1
	for i in range(n - 1, 0, -1):
		if ar[i] <= ar[i + 1]:
			ap[i] = ap[i + 1] + 1
ar = L()
ar.insert(0, 0)
solve(ar)
for i in range(m):
	(l, r) = L()
	x = l + ap[l] + dp[l + ap[l]]
	if x >= r:
		print('Yes')
	else:
		print('No')
endtime = time.time()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys
import math
from math import gcd
import bisect
(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
up = [0] * n
down = [0] * n
i = 0
while i < n:
	j = i
	while j < n - 1 and arr[j] <= arr[j + 1]:
		j += 1
	for var in range(i, j + 1):
		up[var] = j
	i = j + 1
i = 0
while i < n:
	j = i
	while j < n - 1 and arr[j] >= arr[j + 1]:
		j += 1
	for var in range(i, j + 1):
		down[var] = j
	i = j + 1
for i in range(m):
	(l, h) = map(int, input().split())
	var1 = up[l - 1]
	var2 = down[var1]
	if up[l - 1] >= h - 1 or down[l - 1] >= h - 1 or down[up[l - 1]] >= h - 1:
		print('Yes')
	else:
		print('No')


(n, m) = list(map(int, input().split()))
l = list(map(int, input().split()))
l1 = [0] * n
l3 = [0] * n
f = False
v = 0
for i in range(1, n):
	if l[i] < l[i - 1]:
		f = True
		v = i
	if l[i] > l[i - 1] and f:
		f = False
		for j in range(i - 1, v - 1, -1):
			l3[j] = j
		l1[v] = 1
		v = -1
l2 = [0] * n
for i in range(1, n):
	l2[i] = l1[i] + l2[i - 1]
s = []
for i in range(m):
	(a, b) = list(map(int, input().split()))
	t = l2[b - 1] - l2[a - 1]
	if l3[b - 1] >= b - 1:
		t -= 1
	if t > 0:
		s.append('No')
	else:
		s.append('Yes')
print('\n'.join(s))


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 9 + 7
EPS = 1e-06

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
ups = []
downs = []
(n, q) = value()
a = array()
parent = -1
for i in range(n):
	ups.append(parent)
	if i + 1 < n and a[i] < a[i + 1]:
		parent = i
parent = n
for i in range(n - 1, -1, -1):
	downs.append(parent)
	if i - 1 >= 0 and a[i] < a[i - 1]:
		parent = i
downs = downs[::-1]
for i in range(q):
	(l, r) = value()
	if downs[l - 1] > ups[r - 1]:
		print('Yes')
	else:
		print('No')


(n, m) = map(int, input().split())
(*a,) = map(int, input().split())
inc = [*range(n)]
dec = [*range(n)]
for i in range(n - 1, 0, -1):
	if a[i] >= a[i - 1]:
		inc[i - 1] = inc[i]
	if a[i] <= a[i - 1]:
		dec[i - 1] = dec[i]
k = ['No'] * m
l = 0
for (i, j) in (map(lambda i: int(i) - 1, input().split()) for _ in ' ' * m):
	if dec[inc[i]] >= j:
		k[l] = 'Yes'
	l += 1
print('\n'.join(k))


def main(inp):
	(n, m) = split_inp_int(inp)
	arr = split_inp_int(inp)
	inc = [i for i in range(n)]
	dec = [i for i in range(n)]
	for i in range(1, n):
		if arr[i] >= arr[i - 1]:
			inc[i] = inc[i - 1]
		if arr[i] <= arr[i - 1]:
			dec[i] = dec[i - 1]
	for __ in range(m):
		(l, r) = [i - 1 for i in split_inp_int(inp)]
		pivot = dec[r]
		start_inc = inc[pivot]
		if l >= start_inc:
			print('Yes')
		else:
			print('No')

def split_inp_int(inp):
	return list(map(int, inp().split()))

def use_fast_io():
	import sys

	class InputStorage:

		def __init__(self, lines):
			lines.reverse()
			self.lines = lines

		def input_func(self):
			if self.lines:
				return self.lines.pop()
			else:
				return ''
	input_storage_obj = InputStorage(sys.stdin.readlines())
	return input_storage_obj.input_func
from collections import Counter, defaultdict
from functools import reduce
import operator
import math

def product(arr_):
	return reduce(operator.mul, arr_, 1)
main(use_fast_io())


import os

def __starting_point():
	(n, m) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	increase = [-1] * n
	decrease = [-1] * n
	tmp = n - 1
	for i in range(n - 1, -1, -1):
		if i != n - 1:
			if arr[i] > arr[i + 1]:
				tmp = i
		increase[i] = tmp
	tmp = 0
	for i in range(n):
		if i != 0:
			if arr[i - 1] < arr[i]:
				tmp = i
		decrease[i] = tmp
	result = []
	for i in range(m):
		(a, b) = list(map(int, input().split()))
		a -= 1
		b -= 1
		result.append('Yes\n' if increase[a] >= decrease[b] else 'No\n')
	print(''.join(result))
__starting_point()


(n, q) = map(int, input().split())
arr = [int(x) for x in input().split()]
inc = [-1] * n
dec = [-1] * n
inc[n - 1] = n - 1
for i in range(n - 2, -1, -1):
	if arr[i] <= arr[i + 1]:
		inc[i] = inc[i + 1]
	else:
		inc[i] = i
dec[n - 1] = n - 1
for i in range(n - 2, -1, -1):
	if arr[i] >= arr[i + 1]:
		dec[i] = dec[i + 1]
	else:
		dec[i] = i
for i in range(q):
	(l, r) = map(int, input().split())
	if dec[inc[l - 1]] >= r - 1:
		print('Yes')
	else:
		print('No')


from sys import stdin, stdout
(n, m) = map(int, stdin.readline().strip().split())
dp = [1 for i in range(n + 1)]
ap = [1 for i in range(n + 1)]

def solve(ar):
	for i in range(n - 1, 0, -1):
		if ar[i] <= ar[i + 1]:
			dp[i] = dp[i + 1] + 1
	for i in range(1, n + 1):
		if ar[i - 1] >= ar[i]:
			ap[i] = ap[i - 1] + 1
ar = list(map(int, stdin.readline().strip().split()))
ar.insert(0, 0)
solve(ar)
for i in range(m):
	(l, r) = map(int, stdin.readline().strip().split())
	x = ap[r] + dp[l] - 1
	if x >= r - l + 1:
		stdout.write('Yes\n')
	else:
		stdout.write('No\n')


from sys import stdin
input = stdin.readline
[n, q] = [int(item) for item in input().split(' ')]
arr = [int(item) for item in input().split(' ')]
queries = [[int(item) for item in input().split(' ')] for i in range(q)]
b = [1]
for i in range(1, n):
	b.append(b[-1] + 1 if arr[i] <= arr[i - 1] else 1)
c = [1]
for i in reversed(range(n - 1)):
	c.append(c[-1] + 1 if arr[i] <= arr[i + 1] else 1)
c = [item for item in reversed(c)]
for query in queries:
	(x, y) = query
	x -= 1
	y -= 1
	print('Yes' if x + c[x] > y or y - b[y] < x or x + c[x] > y - b[y] else 'No')


M = lambda : map(int, input().split())
L = lambda : list(map(int, input().split()))
I = lambda : int(input())
(n, k) = M()
t = [0] + L()
(a, b) = (list(range(n + 1)), list(range(n + 1)))
for i in range(n, 1, -1):
	if t[i] >= t[i - 1]:
		a[i - 1] = a[i]
	if t[i] <= t[i - 1]:
		b[i - 1] = b[i]
p = ['No'] * k
for i in range(k):
	(x, y) = M()
	if b[a[x]] >= y:
		p[i] = 'Yes'
print('\n'.join(p))


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def case():
	(n, q) = li()
	a = li()
	up = [0] * n
	down = [0] * n
	i = 0
	while i < n:
		j = i
		while j < n - 1 and a[j] <= a[j + 1]:
			j += 1
		for k in range(i, j + 1):
			up[k] = j
		i = j + 1
	i = 0
	while i < n:
		j = i
		while j < n - 1 and a[j] >= a[j + 1]:
			j += 1
		for k in range(i, j + 1):
			down[k] = j
		i = j + 1
	for i in range(q):
		(l, r) = li()
		p = up[l - 1]
		q = down[p]
		if q + 1 >= r:
			print('Yes')
		else:
			print('No')
for _ in range(1):
	case()


import traceback
import math
from collections import defaultdict
from functools import lru_cache
(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
increase = [-1] * n
decrease = [-1] * n
tmp = n - 1
for i in range(n - 1, -1, -1):
	if i != n - 1:
		if arr[i] > arr[i + 1]:
			tmp = i
	increase[i] = tmp
tmp = 0
for i in range(n):
	if i != 0:
		if arr[i - 1] < arr[i]:
			tmp = i
	decrease[i] = tmp
result = []
for i in range(m):
	(a, b) = map(int, input().split())
	a -= 1
	b -= 1
	result.append('Yes\n' if increase[a] >= decrease[b] else 'No\n')
print(''.join(result))