For an array max(a)−min(a)=7−0=7≥5.
You are given an array a, or tell that it doesn't exist.
An array a by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end. In particular, an array is a subarray of itself.
The first line contains integer number t test cases follow.
The first line of each test case contains a single integer 2≤n≤2⋅105) — the length of the array.
The second line of each test case contains 0≤ai≤109) — the elements of the array.
It is guaranteed that the sum of 2⋅105.
For each test case, output "NO" in a separate line if there is no interesting nonempty subarray in a.
Otherwise, output "YES" in a separate line. In the next line, output two integers 1≤l≤r≤n) — bounds of the chosen subarray. If there are multiple answers, print any.
You can print each letter in any case (upper or lower).
3 5 1 2 3 4 5 4 2 0 1 9 2 2019 2020
NO YES 1 4 NO
In the second test case of the example, one of the interesting subarrays is max(a)−min(a)=9−0=9≥4.
/* 只要存在合法字串,那么一定存在长度为2的合法子串 */ #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #define maxn 200010 using namespace std; int a[maxn],n; int main(){ int t; scanf("%d",&t); while(t--){ scanf("%d",&n); for(int i=1;i<=n;i++)scanf("%d",&a[i]); if(n==1){ puts("NO"); continue; } bool flag=0; for(int i=2;i<=n;i++){ if(abs(a[i]-a[i-1])>=2){ flag=1; puts("YES"); printf("%d %d\n",i-1,i); break; } } if(!flag)puts("NO"); } return 0; }