Page 3 of 6
Posted: Thu Jul 28, 2005 8:37 pm
by angga888
Hmm.. weird... It should be correct
Maybe you can check the error message from the email sent by the judge.

Posted: Fri Jul 29, 2005 5:53 am
by kckckc
Thanks
I submit the same code for a few times and finally it "Accepted"
I don't know where the problem is but now is correct

Posted: Sun Jul 31, 2005 10:52 am
by J&Jewel
This is a very interesting problem....
Suddenly may be the judge server some times show false...
I also solve a problem....yesterday it shows w/A.....today it shows ACC...
Very Interesting....
591
Posted: Sun Aug 27, 2006 2:35 am
by Phoenix dark
Can anyone please tell me what's wrong with this code:
#include <stdio.h>
main()
{
int n,h[200],sum=0,sum2=0,h1[100000];
int k=0,i,j;
while(scanf("%d",&n) && n!=0)
{
for(i=0;i<n;i++)
{
scanf("%d",&h);
sum+=h;
}
sum=sum/n;
for(i=0;i<n;i++)
{
if(h-sum>0)
{
sum2+=(h-sum);
}
}
h1[k]=sum2;
k++;
sum=sum2=0;
}
for(j=0;j<k;j++)
{
printf("set #%d\n",j+1);
printf("The minimum number of moves is %d\n\n",h1[j]);
}
return 0;
}
thanks
Posted: Sun Aug 27, 2006 12:19 pm
by kolpobilashi
your mistake is:you take all the inputs together and then print their outputs, but actually this is not the usual style for uva problems.
here you'll have to take an input, then print its output,then take another input........this process will go on until the end of the file.
you can have a look on the sample code provided in this site.
http://online-judge.uva.es/problemset/data/p100.c.html
best regards.

591
Posted: Mon Sep 18, 2006 4:15 pm
by ahah2002
I really can't find any mistakes...Pls help me~~~
#include <iostream>
using namespace std;
int main(){
int count=0;
int block;
long sum;
long result;
long diff;
int i;
do{
sum=0;
result=0;
cin>>block;
if (block==0){
break;}
count++;
int a[block];
for (i=0;i<block;i++){
cin>>a
;
sum+=a;
}
for (i=0;i<block;i++){
diff=a-sum/block;
if (diff>0){
result+=diff;}
}
cout<<"Set #"<<count<<endl;
cout<<"The minimum number of moves is "<<result<<endl<<endl;
} while (1);
return 0;
}
591 with P.E
Posted: Tue Oct 10, 2006 10:14 am
by john_locke
This is my code cant find why i get P.E
plz help me
#include<iostream>
using namespace std;
int main()
{
int i=1,k,h[100];
cin>>k;
while(k!=0)
{
int sum=0;
for(int j=0;j<k;j++)
{
cin>>h[j];
sum=sum+h[j];
}
int t=sum/k;
int s=0;
for(int j=0;j<k;j++)
{
if(h[j]>t)
s=s+(h[j]-t);
}
cout<<"Set #"<<i<<endl;
cout<<"The minimum number of moves is "<<s<<"."<<endl;
cin>>k;
i++;
}
return 0;
}
thanx in advance
Posted: Wed Oct 11, 2006 6:48 am
by augustotorres
Hey...
Try changing line
Code: Select all
cout<<"The minimum number of moves is "<<result<<endl<<endl;
with line
Code: Select all
cout<<"The minimum number of moves is "<<result<<"."<<endl<<endl;
Then, you'll get ACC
Posted: Wed Oct 11, 2006 6:49 am
by augustotorres
Try changing line
Code: Select all
cout<<"The minimum number of moves is "<<s<<"."<<endl;
with line
Code: Select all
cout<<"The minimum number of moves is "<<s<<"."<<endl<<endl;
Good luck
Posted: Fri Dec 08, 2006 7:57 pm
by Debashis Maitra
Please remove your code after AC
591
Posted: Wed Jan 10, 2007 8:14 pm
by dorpon
can any one plz tell me what is the prob in my following program
#include<stdio.h>
main()
{
int x[100],n,i,y,z,l,k,j=1;
while(1)
{
y=0; l=0;
scanf("%d",&n);
if(n==0)
break;
for(i=0;i<n;i++)
{
scanf("%d",&x);
y+=x;
}
z=y/n;
printf("set# %d\n",j);
for(i=0;i<n;i++)
{
if(x>z)
l+=(x-z);
}
printf("The minimum number of moves is: %d\n",l);
j++;
}
}
Posted: Sun Jan 14, 2007 6:43 am
by vijay03
Two things:
should be
And you forgot this line:
Output a blank line after each set.
591: PE problem ...
Posted: Thu Mar 22, 2007 2:47 am
by shumphreys
HI, Having eventually managed to get an AC I know get a PE. I know it's not a major issue but I'd like to clear up what I might have got wrong. I copy below the i/o parts of the cod ein the hope that someone will guide me.
With thanks
Code: Select all
cin >> stackTotal;
// outer loop only entered if the stack total is not zero
...
cin >> stacks[i];
...
// process the stuff and do some calculations
// print out the result
cout << endl << "Set #" << count << endl;
cout << "The minimum number of moves is " << answer << "." << endl << endl;
Posted: Fri Mar 23, 2007 4:09 pm
by abdullah<cse du>
Hi,
There is a wrong in your output section. Your output section is
Code: Select all
cin >> stackTotal;
// outer loop only entered if the stack total is not zero
...
cin >> stacks[i];
...
// process the stuff and do some calculations
// print out the result
cout << endl << "Set #" << count << endl;
cout << "The minimum number of moves is " << answer << "." << endl << endl;
Change it to
I think it will help you.
ABDULLAH.
Posted: Sun Mar 09, 2008 10:01 pm
by scott1991
can someone please give me some help in speeding up my program as i'm getting tle...
Code: Select all
#include <iostream>
int main()
{
int n,h=0,average=0,moves=0,set=1;
int* heights = new int [60];
a:
scanf("%d",&n);
if(n<1)
{
return 0;
}
else
{
while(h<n)
{
scanf("%d",&heights[h]);
average+=heights[h];
h++;
}
h=0;
average=average/n;
while(h<n)
{
if(heights[h]>average)
{
moves+=heights[h]-average;
}
h++;
}
printf("Set #%d\nThe minimum number of moves is %d.\n\n",set,moves);
moves=0;set++;
goto a;
}
}
thanks