Source Code
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,k1,k2,k3;
vector<int>v((int)2e5+1);
void lets_hope_its_right(){
    cin>>n>>k1>>k2>>k3;
    v.resize(n);
    for(int i=0;i<n;i++) cin>>v[i];
    int l=0,r=1,len=0;
    pair<int,int>ans={};
    for(int i=1;i<n;i++){
        bool t1=0,t2=0,t3=0;
        if(abs((v[i]%4)-(v[i-1]%4))<=k1) t1=1;
        if(abs((v[i]%5)-(v[i-1]%5))<=k2) t2=1;
        if(abs((v[i]%8)-(v[i-1]%8))<=k3) t3=1;
        if(t1&&t2&&t3){
            r++;
            if(r-l+1>len){
                ans.first=l;
                ans.second=r;
            }
        }
        else l=r,r++;
    }
    cout<<ans.first+1<<' '<<ans.second;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tt=1; //cin>>tt;
    while(tt--) lets_hope_its_right();
}
Copy
Band Song 1 YazanIstatiyeh
GNU G++17
12 ms
1.5 MB
Wrong Answer