CF1923C.Find B
普及/提高-
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
An array a of length m is considered good if there exists an integer array b of length m such that the following conditions hold:
- i=1∑mai=i=1∑mbi;
- ai=bi for every index i from 1 to m;
- bi>0 for every index i from 1 to m.
You are given an array c of length n. Each element of this array is greater than 0.
You have to answer q queries. During the i-th query, you have to determine whether the subarray cli,cli+1,…,cri is good.
长度为 m 的数组 a 被称为好数组,当且仅当存在一个长度为 m 的整数数组 b,满足以下条件:
- i=1∑mai=i=1∑mbi;
- 对每个下标 i(1≤i≤m),均有 ai=bi;
- 对每个下标 i(1≤i≤m),均有 bi>0。
给定一个长度为 n 的数组 c,其中每个元素均大于 0。
你需要回答 q 个查询。在第 i 个查询中,你需要判断子数组 cli,cli+1,…,cri 是否为好数组。
输入格式
The first line contains one integer t (1≤t≤104) — the number of test cases.
The first line of each test case contains two integers n and q (1≤n,q≤3⋅105) — the length of the array c and the number of queries.
The second line of each test case contains n integers c1,c2,…,cn (1≤ci≤109).
Then q lines follow. The i-th of them contains two integers li and ri (1≤li≤ri≤n) — the borders of the i-th subarray.
Additional constraints on the input: the sum of n over all test cases does not exceed 3⋅105; the sum of q over all test cases does not exceed 3⋅105.
第一行包含一个整数 t(1≤t≤104)——测试用例的数量。
每个测试用例的第一行包含两个整数 n 和 q(1≤n,q≤3⋅105)——数组 c 的长度和查询次数。
每个测试用例的第二行包含 n 个整数 c1,c2,…,cn(1≤ci≤109)。
接下来是 q 行,其中第 i 行包含两个整数 li 和 ri(1≤li≤ri≤n)——第 i 个子数组的左右边界。
输入的额外约束:所有测试用例的 n 之和不超过 3⋅105;所有测试用例的 q 之和不超过 3⋅105。
输出格式
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.
对于每个查询,如果子数组是“好”的,则输出 YES;否则输出 NO。
答案的每个字母可以是任意大小写(大写或小写)。例如,字符串 yEs、yes、Yes 和 YES 均会被识别为肯定回答。
输入输出样例
输入#1
1 5 4 1 2 1 4 5 1 5 4 4 3 4 1 3
输出#1
YES NO YES NO
输入解题思路,AI测评打分。不知道怎么写?