Daffodil International University
Problem Link
//Please follow from main function
#include<bits/stdc++.h>
using namespace std;
vector<int>arr;
int main()
{
int n, sum;
cin>>n;
vector<int>num(n+5);
for(int i=0; i<n; i++){
int d;
cin>>d;
num[d]++;
}
for(int i=0; i<num.size()-1; i++){
sum=num[i]+num[i+1];
arr.push_back(sum);
}
sort(arr.begin(), arr.end(), greater<int>());
cout<<arr[0]<<endl;
return 0;
}
0 Comments