10041 - Vito's Family

All about problems in Volume 100. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

midobo
New poster
Posts: 5
Joined: Sat Jul 19, 2008 12:24 pm

Re: 10041 - Vito's Family

Post by midobo »

Obaida wrote:Remove the exit(0); function. This is not valid.
Hope you get Accepted & remove the code. :wink:
Thanks Obaida for your replying
i have do what u tell me but still runtime error and this is the UVa mail to me:
Your submission for the problem 10041 - Vito's Family has failed with verdict Runtime error.
This means that the execution of your program didn't finish properly. Remember to always terminate your code with the exit code 0.
PLZ Reply me I really need help

Thanks in advance
Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Re: 10041 - Vito's Family

Post by Obaida »

I just removed the #include<stdlib.h>
and exit(0);
Then i got Accepted!
try_try_try_try_&&&_try@try.com
This may be the address of success.
midobo
New poster
Posts: 5
Joined: Sat Jul 19, 2008 12:24 pm

Re: 10041 - Vito's Family

Post by midobo »

thanx Obaida for replying me
but there is something wrong
how you remove the #include<stdlib.h> and got AC
there is (abs) function that found on this library
i do what you tell me but this is the UVa mail to me:
Your submission for the problem 10041 - Vito's Family has failed with verdict Runtime error.
there is still an error, and i don't know what is it?? :( :( :( :cry: :cry:

PLZ Reply me.Thanks
midobo
New poster
Posts: 5
Joined: Sat Jul 19, 2008 12:24 pm

Re: 10041 - Vito's Family

Post by midobo »

Please i really need help :cry: :-?
i want to know what is wrong??
plz any one reply me
Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Re: 10041 - Vito's Family

Post by Obaida »

you shouldn't use abs. :wink:
try_try_try_try_&&&_try@try.com
This may be the address of success.
midobo
New poster
Posts: 5
Joined: Sat Jul 19, 2008 12:24 pm

Re: 10041 - Vito's Family

Post by midobo »

Dear Obaida,
PLZ can you change my code and send it
i did all you said but still Runtime Error
Thanks
wahp
New poster
Posts: 1
Joined: Thu Oct 23, 2008 10:37 pm

Re: 10041 - Vito's Family

Post by wahp »

hello guys
how are u?
i have a problem that i have that error in a simple problem
although this code compile and run correctly in my machine

this is the error :
Vito's Family has failed with verdict Runtime error.


This means that the execution of your program didn't finish properly. Remember to always terminate your code with the exit code 0.

this is the code:

Code: Select all

#include<stdio.h>

int bubSort(int arr[],int length)
{
	int temp;
	for(int i=length-1;i>=0;i--)
	{
		
		for(int k=0;k<i;k++)
		{
			if(arr[k]>arr[k+1])
			{
				int temp=arr[k+1];
				arr[k+1]=arr[k];
				arr[k]=temp;
			}
		}	
	}
	return 0;
}

int main()
{
	int N,path[100];
	scanf("%d",&N);
	for(int k=0;k<N;k++)
	{
		int Case[100],n;
		scanf("%d",&n);
		for(int i=0;i<n;i++)
		{
			scanf("%d",&Case[i]);	
		}

		bubSort(Case,n);
		path[k]=0;
		for(int m=0;m<n-1;m++)
		{
			int temp=((Case[m])-(Case[m+1]));
			if(temp<0)
				temp*=-1;
			path[k]+=temp;
		}		

	}

	for(int m=0;m<N;m++)
	{
		printf("%d\n",path[m]);
	}

	return 0;

}


please neeed ur help

thanks in advance
bye
ExUCI
New poster
Posts: 14
Joined: Sat Aug 12, 2006 3:31 am
Location: USA

Re: 10041 - Vito's Family

Post by ExUCI »

It might be late, but clearly one thing wrong in your code it's the range...the problem says 0 < r < 500
Aumy
New poster
Posts: 2
Joined: Sat Mar 21, 2009 7:05 am

Re: 10041 - Vito's Family

Post by Aumy »

I am getting WA . PLS someone help whats the problem :(

Code: Select all

removed after AC
Last edited by Aumy on Wed Jul 29, 2009 4:25 pm, edited 1 time in total.
mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Re: 10041 - Vito's Family

Post by mf »

Code: Select all

      for(i = 1 ; i < s ; i++)
      {
         int j;
         for(j = i ; j < s ; j++)
         {
            if(A[j]<A[j-1])
            {
               int t = A[j];
               A[j] = A[j-1];
               A[j-1] = t;
            }
         }
      }
This isn't a correct sorting procedure.

Why do you feel the need to reinvent the wheel? Sorting is "solved", it's a library routine in every major programming language these days. All it takes to sort an array in C++ is just

Code: Select all

#include <algorithm>
...
std::sort(A, A+s);
And I also don't see the point in using dynamic memory allocation here. In most ICPC problems, you're better off using just static arrays, or std::vector at least.
wawa
New poster
Posts: 5
Joined: Thu Dec 16, 2010 8:17 am

Re: 10041 - Vito's Family

Post by wawa »

Hey, can someone help me listing any critical inputs for this problem..???? I 'm tired of getting WA for "Vito's Family"... X(
....thx...

Code: Select all

#include <iostream>
using namespace std;
int main()
{
	int N, R, dif, temp;
	int *S;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		dif = 0;
		cin >> R;
		S = new int[R];
		for (int i = 0; i < R; i++)
			cin >> S[i];
		for (int i = 1; i < R; i++)
			for (int j = i; j > 0; j--)
				if (S[j] < S[j-1])
				{
					temp = S[j];
					S[j] = S[j-1];
					S[j-1] = temp;
				}
		for (int i = 0; i < R - 1; i++)
			dif += S[i+1] - S[i];
		cout << dif << endl;
	}
	return 0;
}
Is there something wrong w the code....???
asif_iut
New poster
Posts: 16
Joined: Mon Nov 01, 2010 8:08 am

Re: 10041 - Vito's Family

Post by asif_iut »

your logic is wrong.....
consider the test case:
1
4 1 2 4 5
the answer is 6( vito should build his house in 3 ) but your output is 4.
shanto_0321
New poster
Posts: 4
Joined: Sun Sep 11, 2011 8:12 am

Re: 10041 - Vito's Family

Post by shanto_0321 »

#include<stdio.h>
#include<stdlib.h>
int main()
{
int t,N,a[100],m,count=0,i,j,temp,x,min;
while(scanf("%d",&t)!=EOF)
{
for(j=1;j<=t;j++)
{
scanf("%d",&N);
count=0;
for(i=1;i<=N;i++)
{
scanf("%d",&a);
}
for(i=1;i<=N;i++)
for(j=1;j<=N-1-i;j++)
{
if(a[j]>a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}


x=N/2;
for(i=1;i<=N;i++)
{
count+=abs(a[x]-a);
}
printf("%d\n",count);
}
}

return 0;
}
why time limit are shown?
riham awara
New poster
Posts: 1
Joined: Wed Nov 23, 2011 10:42 am

why wrong!! 10041 - Vito's Family

Post by riham awara »

here is my code plz help

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int comp(const void *a,const void *b)
{
int *x=(int *)a;
int *y=(int *)b;
return *x-*y;
}

int main()
{
int test,n,i,sum,mid,middian,input[30002];
scanf("%d",&test);
while(test--)
{
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&input);
}
qsort(input,n,sizeof(input[0]),comp);
mid=n/2;
if(n&1==0) middian=(input[mid]+input[mid-1])/2;
else middian=input[mid];
sum=0;
for(i=0;i<n;i++)
{
sum+=(labs(middian-input));
}
printf("%d\n",sum);
}
return 0;
}
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: why wrong!! 10041 - Vito's Family

Post by brianfry713 »

Nothing is wrong with your code.
Check input and AC output for thousands of problems on uDebug!
Post Reply

Return to “Volume 100 (10000-10099)”