Advertisement
lily09290110

b162 zerojude

Jan 31st, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. int cmp(const void *a,const void *b)
  4. {
  5.     int x=*(int *)a;
  6.     int y=*(int *)b;
  7.     return (x<y?-1:x>y?1:0);
  8. }
  9. int main()
  10. {
  11.     int number[200005],n,i;
  12.     int count=0;
  13.     while(~scanf("%d",&n))
  14.     {
  15.         for(i=0;i<n;i++) scanf("%d",&number[i]);
  16.         qsort(number,i,4,cmp);
  17.         number[n]=-1;
  18.         for(i=0;i<n;i++)
  19.         {
  20.             count++;
  21.             if(number[i]!=number[i+1])
  22.             {
  23.                 printf("%d %d\n",number[i],count);
  24.                 count=0;
  25.             }
  26.         }
  27.     }
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement