ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1917. Titan Ruins: Deadly Accuracy

WA #22
Posted by Rapheal Chen 10 Mar 2013 08:41
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
Posted by Petru Trimbitas 23 Apr 2013 03:08
you can cast a spell with power of p