You are viewing a single comment's thread. Return to all comments →
this passes all test cases.
int cmpfunc (const void * a, const void * b)
{ return ( (int)a - (int)b ); }
int main() {
int n,i,x,y,c=1; int a[100000]={0}; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d",&a[i]); qsort(a, n, sizeof(a[0]), cmpfunc); x=a[0]; y=x+4; for(i=0;i<n;i++) { if(a[i]>=x && a[i]<=y) continue ; else { c++; x=a[i]; y=x+4; } } printf("%d",c); return 0;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Priyanka and Toys
You are viewing a single comment's thread. Return to all comments →
this passes all test cases.
int cmpfunc (const void * a, const void * b)
{ return ( (int)a - (int)b ); }
int main() {
}