Source Code
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <list>


using namespace std;



int main()
{
   int n,k1,k2,k3,l=0,r=0;
   scanf("%d %d %d %d",&n,&k1,&k2,&k3);
   int a[n];
   for(int i=0; i<n; i++)
   {
       scanf("%d",&a[i]);
   }
   for(int i=0; i<n-1; i++)
   {
       int s=abs(a[i]-a[i+1]),l2=0,r2=0;
       if(s%4<=k1 && s%5<=k2 && s%8<=k3)
       {
           l2=i;
           while (i<n-1)
           {
               i++;
               if(s%4>k1 || s%5>k2 || s%8>k3)
                    break;
           }
           r2=i;
       }
       if(r2-l2>l-r)
       {
           l=l2;
           r=r2;
       }
   }
    printf("%d %d", l,r);

}
Copy
Band Song 1 Abbro
GNU G++17
13 ms
1.3 MB
Wrong Answer