Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- int cmp(const void *a,const void *b)
- {
- int x=*(int *)a;
- int y=*(int *)b;
- return (x<y?-1:x>y?1:0);
- }
- int main(i)
- {
- int limt,n,number[30005],count=0;
- int lef_flag,right_flag;
- while(~scanf("%d",&limt))
- {
- count=0;
- for(scanf("%d",&n),i=0;i<n;i++)scanf("%d",&number[i]);
- qsort(number,i,4,cmp);
- lef_flag=0;right_flag=i-1;
- while(right_flag>=lef_flag)
- {
- if((number[lef_flag]+number[right_flag])>limt)
- {
- count++;
- right_flag--;
- }
- else
- {
- count++;
- lef_flag++;
- right_flag--;
- }
- }
- printf("%d\n",count);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement