Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main()
- {
- int n,c=0,max=0;
- cin >> n;
- long long a[n+1];
- for (int i=0; i<n;i++) cin >> a[i];
- sort(a,a+n);
- a[n+1]=60001;
- for (int i=0; i<n;i++ ) cout << a[i] << ' ';
- for(int i=0; i<n-1; i++){
- if(a[i]==a[i+1]+1)
- c++;
- else{
- if(a[i]!=a[i+1]){
- if(c>max){
- max=c;
- c=0;
- }
- }
- }
- }
- cout<< endl << max;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement