142012025-01-10 09:01:52badamSíkság (55)cpp17Time limit exceeded 19/55300ms736 KiB
#include <iostream>

using namespace std;

int main()
{
  int n;
  int a=0;
  int b=0;
  int c=0;
  int m=0;
  int x=0;
  int z=0;
  int l=0;
  cin >> n;
  int t[n];
  for(int i=0;i<n;i++) cin >> t[i];
  for(int i=0; i<n;i++)
  {
      for(int p=i; p<n;p++)
      {
          if(t[p]==t[i])
          {
           a++;
          }
          if(t[p]==t[i]+1)
          {
              b++;
          }
          if(t[p]==t[i]-1)
          {
              c++;
          }
                 if (a+b==p-i+1 or a+c==p-i+1)
          {
              x=p-i+1;

          if (x>z)
          {
              z=x;
              l=i+1;
          }
          x=0;

          }

      }
      a=0;
      b=0;
      c=0;

  }
  cout << z << " " << l;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base19/55
1Accepted0/01ms316 KiB
2Time limit exceeded0/0211ms316 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms316 KiB
7Accepted3/31ms316 KiB
8Accepted2/23ms512 KiB
9Accepted3/33ms316 KiB
10Time limit exceeded0/3217ms316 KiB
11Accepted3/3177ms436 KiB
12Time limit exceeded0/3298ms428 KiB
13Time limit exceeded0/3282ms564 KiB
14Time limit exceeded0/3300ms584 KiB
15Time limit exceeded0/3284ms564 KiB
16Time limit exceeded0/3286ms564 KiB
17Time limit exceeded0/3282ms564 KiB
18Time limit exceeded0/3300ms736 KiB
19Time limit exceeded0/3280ms564 KiB
20Time limit exceeded0/3280ms528 KiB
21Time limit exceeded0/3287ms564 KiB
22Time limit exceeded0/3300ms568 KiB