Advertisement
lily09290110

d150 ZERIJUDE

Jan 31st, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 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(i)
  10. {
  11.     int number[20002],n,m,sum;
  12.     for(scanf("%d",&n);n>0;n--)
  13.     {
  14.         sum=0;
  15.         for(scanf("%d",&m),i=0;i<m;i++) scanf("%d",&number[i]);
  16.         qsort(number,m,4,cmp);
  17.         number[m]=0;
  18.         for(i=m;i>=0;i-=3) sum+=number[i];
  19.         printf("%d\n",sum);
  20.     }
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement