Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
how can this receive "runtime error"?#include <stdio.h> int cmp(const void *p,const void *q) { return *(long *)p > *(long *)q; } int main() { int n,i,j,count; long s,cow[20000]; scanf("%d%d",&n,&s); for(i = 0;i<n;i++) scanf("%d",&cow[i]); qsort(cow,n,sizeof(long),cmp); i = 0; j = n-1; count = 0; while(1) { while(cow[i]+cow[j] > s) j--; count += (j-i); if (j - i == 1) break; j = n-1; i++; } printf("%d\n",count); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator