KDOMINO - K-dominant array

题意翻译

## 【题目大意】 你有一个长度为 $n$ 的数列 $a$ ,有 $q$ 次询问,每次询问给出三个整数:$l$,$r$,$k$。询问若区间 $[l,r]$ 的众数的出现次数为 $s$,比较 $s\times k$ 和 $r - l + 1$ 的大小,如果前者大于等于后者,那么输出 ```YES```,否则输出```NO```。 ## 【输入格式】 第一行两个整数 $n,q$。 第二行 $n$ 个整数 $a_1,a_2,\dots a_n$,表示题目中给的数列。 第三到第 $2+q$ 行,三个整数 $l,r,k$。 ## 【输出格式】 $q$ 行,输出每一次询问的答案。 ## 【数据范围】 $0 < n,q \le 2\times 10^5$,$0< \sum k \le 5\times 10^5$,$0<l,r\le n$。 保证输入的所有数字在 ```int``` 范围内

题目描述

Professor Mahammad was sitting in his garden when an apple fell on his head, and in a stroke of brilliant insight, he suddenly came up with _K-dominant notation_. An array with length _L_ is called _K-dominant_, if and only if there is at least one element _x_ lying in the array for which **occurence(x) \* K >= L**. After analyzing several arrays with this property, professor now, made up a new problem for you. Your task is simple, there are given an array of length N and several queries. For each of the queries, you just need to check whether _the subarray \[l, r\] is k-dominant or not_.

输入输出格式

输入格式


The first line of the input contains two positive integers **N** and **Q**, the number of elements of the array and the mean, respectively. (**N, Q ).** The following line contains N integers which represent elements of the array. The following Q lines contains three integers **l**, **r**, and **k**. (**1 ).** **All the numbers in the input section are 32-bit positive integers.** **Sum of all k's in queries does not exceed 500000.**

输出格式


For each of the queries, print per line **YES** or **NO** if there is an element lying in the subarray which satisfies the condition in the statement.

输入输出样例

输入样例 #1

8 3
1 4 2 3 2 2 5 3
2 6 2
1 8 2
1 8 3

输出样例 #1

YES
NO
YES