Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define fastread()(ios_base::sync_with_stdio(false),cin.tie(NULL));
- #define ll long long
- int main()
- {
- fastread()
- ll t;
- cin>>t;
- while(t--)
- {
- ll n,cnt, mn, mx, i;
- cin>>n;
- ll ara[n+1];
- for(i=0; i<n; i++)
- cin>>ara[i];
- sort(ara,ara+n);
- mx=0,mn=1e9,cnt=0;
- for(i=0; i<n-1; i++)
- {
- if(abs(ara[i]-ara[i+1])<3)
- {
- cnt++;
- }
- else
- {
- mn=min(cnt,mn);
- mx=max(mx,cnt);
- cnt = 0;
- }
- }
- mn=min(cnt,mn);
- mx=max(mx,cnt);
- cout<<mn+1<<" "<<mx+1<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment