|
|
back to boardWA #22 what is test 22? i wa 22 what's wrong? #include<stdio.h> #include<string.h> int n,p,a[1000010],min=1000000,max=0,sum=0,ans=0; int main() { int i,x,j,k; memset(a,0,sizeof(a)); scanf("%d%d",&n,&p); for(i=1; i<=n; i++) { scanf("%d",&x); a[x]++; if(x<min) min=x; if(x>max) max=x; } for(i=min; i<=max; i++) if(a[i]!=0) { if(a[i]*i>=p) break; sum+=a[i]; ans++; } for(k=min; k<i; k++) if(a[k]!=0){ for(j=k+1; j<i; j++) if(a[j]!=0) break; if(a[j]==0) break; if(j*(a[k]+a[j])<p) { ans--; a[j]+=a[k]; a[k]=0; } } printf("%d %d\n",sum,ans); return 0; } Edited by author 10.03.2013 08:41 呃…… Edited by author 10.03.2013 08:48 Edited by author 10.03.2013 08:48 Re: WA #22 you can cast a spell with power of p |
|
|