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 |
maxn 不是50;而且你没考虑N=1的情况In Reply To:我的怎么会WA?今晚太郁闷了,两道题,WA了15次,没AC一个 Posted by:jiaohang at 2006-10-20 21:25:24 > #include <stdio.h> > #include<stdlib.h> > #define maxn 50 > long long w[maxn],s[maxn],num[maxn]; > int N; > int cmp(const void *a,const void*b) > { > return w[*(long long*)a]+s[*(long long*)a]-w[*(long long*)b]-s[*(long long*)b]; > } > int main() > { > scanf("%d",&N); > for(int i=0;i<N;++i) > { > scanf("%lld%lld",w+i,s+i); > num[i]=i; > } > qsort(num,N,sizeof(long long),cmp); > long long r=0,R,flag=1; > for(int i=1;i<N;++i) > { > r+=w[num[i-1]]; > > if(r-s[num[i]]>R||flag) > { > R=r-s[num[i]]; > flag=0; > } > } > printf("%lld",R); > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator