ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
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