1 solutions
-
0
C++ :
#include<bits/stdc++.h> using namespace std; const int N=1e5+10; int n,a[N]; int main(){ cin>>n; for(int i=0;i<n;i++){ cin>>a[i]; } sort(a,a+n); int len=unique(a,a+n)-a; //cout<<len; int ans=1,maxn=-1; for(int i=0;i<len-1;i++){ if(a[i]+1==a[i+1]){ ans++; maxn=max(maxn,ans); }else{ ans=1; } } cout<<maxn; return 0; }
- 1
Information
- ID
- 166
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- 10
- Tags
- # Submissions
- 1
- Accepted
- 1
- Uploaded By