Advertisement
Sanzida

UVA 957

Aug 24th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.62 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int arr[100010];
  5.     int y,n;
  6.     while(scanf("%d",&y)==1)
  7.     {
  8.         scanf("%d",&n);
  9.         int i,j,a,b,count=0,max=0;
  10.         for(i=0;i<n;i++)
  11.         {
  12.             scanf("%d",&arr[i]);
  13.         }
  14.         for(i=0;i<n;i++)
  15.         {
  16.             count=0;
  17.             for(j=i;j<n&&arr[j]<arr[i]+y;j++)
  18.             {
  19.                     count++;
  20.             }
  21.             if(count>max)
  22.             {
  23.                 max=count;
  24.                 a=arr[i];
  25.                 b=arr[j-1];
  26.             }
  27.         }
  28.         printf("%d %d %d\n",max,a,b);
  29.     }
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement