Saleh127

UVA 957

Sep 15th, 2020
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define Faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. int main()
  7. {
  8. Faster
  9. ll y,n;
  10. while(cin>>y && y)
  11. {
  12. cin>>n;
  13. ll a[n],c,d,e,f,i,j,maxx=0,lo,hi;
  14. for(i=0;i<n;i++)
  15. {
  16. cin>>a[i];
  17. }
  18. for(i=0;i<n;i++)
  19. {
  20. c=0;
  21. j=i;
  22. ll limit=a[i]+y-1;
  23. while(a[j]<=limit)
  24. {
  25. c++;
  26. j++;
  27. }
  28. if(c>maxx)
  29. {
  30. maxx=c;
  31. lo=a[i];
  32. hi=a[j-1];
  33. }
  34. }
  35. printf("%lld %lld %lld\n",maxx,lo,hi);
  36. }
  37. return 0;
  38. }
  39.  
  40.  
Advertisement
Add Comment
Please, Sign In to add comment