SHARE
TWEET

Untitled

a guest Nov 17th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n,c=0,max=0;
  8.     cin >> n;
  9.     long long a[n+1];
  10.     for (int i=0; i<n;i++) cin >> a[i];
  11.     sort(a,a+n);
  12.     a[n+1]=60001;
  13.     for (int i=0; i<n;i++ ) cout << a[i] << ' ';
  14.     for(int i=0; i<n-1; i++){
  15.         if(a[i]==a[i+1]+1)
  16.             c++;
  17.         else{
  18.             if(a[i]!=a[i+1]){
  19.                 if(c>max){
  20.                     max=c;
  21.                     c=0;
  22.                 }
  23.             }
  24.  
  25.         }
  26.     }
  27.     cout<< endl << max;
  28.  
  29.  
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top