(Good Bye 2019) Codeforces 1270B Interesting Subarray
题目链接:
Codeforces 1270B Interesting Subarray
思路:
如果所有相邻的数差距都小于2,则输出NO;
反之如果大于等于2,相邻的那两个数就符合要求;
代码:
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
#define fi first
#define sc second
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pt(a) cerr<<a<<"---\n"
#define rp(i,n) for(int i=0;i<n;i++)
#define rpn(i,n) for(int i=1;i<=n;i++)
const int maxn=2e5+5;
int a[maxn];
int main(){
ios::sync_with_stdio(false); cin.tie(nullptr);
int t; cin>>t;
while(t--){
int n; cin>>n;
rp(i,n) cin>>a[i];
int x=-1,y=-1;
for(int i=1;i<n;i++){
if(abs(a[i]-a[i-1])>1){
x=i-1; y=i; break;
}
}
if(~x) cout<<"YES\n"<<x+1<<' '<<y+1<<'\n';
else cout<<"NO\n";
}
return 0;
}