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 |
为什么会错呢?该怎么贪心呢?#include<stdio.h> long used[10001]; int main() { long i,j,n,ans; int bin,m; scanf("%ld",&n); memset(used,0,sizeof(used)); for(i=0;i<n;i++) { scanf("%d",&m); used[m]++; } ans=0; ans+=used[bin]; for(i=bin-1;i>=0;i--) { while(used[i]) { used[i]--; ans++; for(j=bin-i>i?i:bin-i;j>=0;j--) if(used[j])break; if(j>=0)used[j]--; } } printf("%ld\n",ans); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator