Source Code
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <string>
using namespace std;
typedef long double ld;
typedef long long ll;
const int N=2e6+5;

int n,k1,k2,k3;
vector <int>v1,v2,v3;
int main(){
ios_base::sync_with_stdio(false);cin.tie (0);
cin>>n>>k1>>k2>>k3;
for (int i=0;i <n;i++){
int a;cin>>a;
v1.push_back(a%4);
v2.push_back(a%5);
v3.push_back(a%8);
}
int ans=1;
int tmp=1;
int r=1;
for (int i=1;i <n;i++){
if (abs (v1 [i]-v1 [i-1])<=k1
&&abs (v2 [i]-v2 [i-1])<=k2
&&abs (v3 [i]-v3 [i-1])<=k3){
tmp++;
}else {
if (tmp>ans){
ans=tmp;
r=i;
}
tmp=1;
}
}
if (tmp>ans){
ans=tmp;r=n;
}
cout <<r-ans+1 <<' '<<r;
}
Copy
Band Song 1 FEAR
GNU G++17
27 ms
2.9 MB
Accepted