CF1923C.Find B

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

An array aa of length mm is considered good if there exists an integer array bb of length mm such that the following conditions hold:

  1. i=1mai=i=1mbi\sum\limits_{i=1}^{m} a_i = \sum\limits_{i=1}^{m} b_i ;
  2. aibia_i \neq b_i for every index ii from 11 to mm ;
  3. bi>0b_i > 0 for every index ii from 11 to mm .

You are given an array cc of length nn . Each element of this array is greater than 00 .

You have to answer qq queries. During the ii -th query, you have to determine whether the subarray cli,cli+1,,cric_{l_{i}}, c_{l_{i}+1}, \dots, c_{r_{i}} is good.

输入格式

The first line contains one integer tt ( 1t1041 \le t \le 10^4 ) — the number of test cases.

The first line of each test case contains two integers nn and qq ( 1n,q31051 \le n, q \le 3 \cdot 10^5 ) — the length of the array cc and the number of queries.

The second line of each test case contains nn integers c1,c2,,cnc_1, c_2, \dots, c_n ( 1ci1091 \le c_i \le 10^9 ).

Then qq lines follow. The ii -th of them contains two integers lil_i and rir_i ( 1lirin1 \le l_i \le r_i \le n ) — the borders of the ii -th subarray.

Additional constraints on the input: the sum of nn over all test cases does not exceed 31053 \cdot 10^5 ; the sum of qq over all test cases does not exceed 31053 \cdot 10^5 .

输出格式

For each query, print YES if the subarray is good. Otherwise, print NO.

You can output each letter of the answer in any case (upper or lower). For example, the strings yEs, yes, Yes, and YES will all be recognized as positive responses.

输入输出样例

  • 输入#1

    1
    5 4
    1 2 1 4 5
    1 5
    4 4
    3 4
    1 3

    输出#1

    YES
    NO
    YES
    NO
首页