10656 - Maximum Sum (II)

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

Moderator: Board moderators

sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

defn of subsequence...

Post by sohel »

Definition of subsequence : subsequence is a term used to mean a sequence derived from a sequence S by discarding some of its terms.
-- from mathworld

So, in the above example 2 5 is a subsequence of the given sequence.

CodeMaker
Experienced poster
Posts: 183
Joined: Thu Nov 11, 2004 12:35 pm
Location: AIUB, Bangladesh

Post by CodeMaker »

hmm, thanks... looks like I have problems in basic :oops:
Jalal : AIUB SPARKS

Stummer
New poster
Posts: 12
Joined: Sat Jul 01, 2006 12:16 pm
Location: Munich, Germany

Post by Stummer »

Thanks to Adrian Kuegel :wink: !!! At last I got Accepted!

bishop
New poster
Posts: 43
Joined: Fri May 04, 2007 12:57 pm

can anyone tell why WA

Post by bishop »

why this is wa
is there any critical way to solve
this

Code: Select all



darkos32
New poster
Posts: 27
Joined: Tue Jul 25, 2006 8:10 am
Location: Indonesia
Contact:

asd

Post by darkos32 »

i got PE..can someone help me give me the sample input and output...

this is my code :

Code: Select all

got accepted..
thanks..

alamgir kabir
New poster
Posts: 37
Joined: Wed Oct 03, 2007 10:42 am

Post by alamgir kabir »

Code: Select all

//remove
Thanks Jan for helping me.
Last edited by alamgir kabir on Wed Nov 14, 2007 3:06 pm, edited 2 times in total.

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

Check the set very carefully.

Input:

Code: Select all

6
1
0
3
4
0
1
0
Output:

Code: Select all

1 3 4 1
Hope you get accepted.
Ami ekhono shopno dekhi...
HomePage

alamgir kabir
New poster
Posts: 37
Joined: Wed Oct 03, 2007 10:42 am

Post by alamgir kabir »

I do not consider this case.
Now I have acc it.
Thanks a lot Jan. I am greatful to u.

Code: Select all

//code removed
Thanks for helping me.
I hope u wil help me in future.
Last edited by alamgir kabir on Sun Nov 18, 2007 5:51 pm, edited 3 times in total.

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

Try the case.

Input:

Code: Select all

3
0
0
0
0
Output:

Code: Select all

0
Hope it helps.
Ami ekhono shopno dekhi...
HomePage

kbr_iut
Experienced poster
Posts: 103
Joined: Tue Mar 25, 2008 11:00 pm
Location: IUT-OIC, DHAKA, BANGLADESH
Contact:

Re: 10656 - Maximum Sum (II)getting PE

Post by kbr_iut »

now AC, code removed
It is tough to become a good programmer.
It is more tough to become a good person.
I am trying both...............................

asif.mist
New poster
Posts: 3
Joined: Wed Jan 26, 2011 4:43 pm

Re: 10656 - Maximum Sum (II)

Post by asif.mist »

is there any trailing space??
i got 5 PE....

aaa111
New poster
Posts: 14
Joined: Sat Nov 21, 2009 2:55 pm

Re: 10656 - Maximum Sum (II)

Post by aaa111 »

I am getting PE,please help:

Code: Select all

#include<stdio.h>

#define SIZE 1010

int main(void)
{
	int i,j,n,flag=0;
	unsigned int num[SIZE];

	while(1)
			{
			flag=0;
			scanf("%d",&n);
			if(n==0)
				break;
			for(i=0;i<n;i++)
				scanf("%u",&num[i]);
			
			if(num[0]==0)
				flag=1;

			i=0;
			if(flag==1)
				while((num[i]==0) && (i<n))
					i++;
					
			if(i==n)
				 printf("0");
			else
				{
					for(j=i;j<n;j++)
						{
							if(num[j]!=0)
								{
								printf("%u",num[j]);
								if(j!=(n-1))
									printf(" ");
								}
						}
				}
	
			printf("\n");
			}
	
	return 0;
}

plamplam
Experienced poster
Posts: 150
Joined: Fri May 06, 2011 11:37 am

Re: 10656 - Maximum Sum (II)

Post by plamplam »

Very easy problem
As the numbers are all non-negative, when you are taking input just store the number in an array if the number is not equal to 0. And later just print the array(with no trailing spaces).
You tried your best and you failed miserably. The lesson is 'never try'. -Homer Simpson

blckhrt
New poster
Posts: 2
Joined: Wed May 04, 2011 8:25 pm
Location: Chittagong
Contact:

Re: 10656 - Maximum Sum (II)

Post by blckhrt »

pls help..um continuosly getting wa in this code..wat's wrong???


#include<stdio.h>
int main()
{
long long int n,i,j,k,flag,num[10000];
while(scanf("%lld",&n)==1)
{
if(n==0)
break;
flag=0;
for(i=0;i<n;i++)
{
scanf("%lld",&num);
if(num==0)
{
flag++;
}
}

if(flag==n)
printf("0\n");
else
{
for(j=0;j<n;j++)
{
if(num[j]==0)
continue;
printf("%lld ",num[j]);
}

printf("\n");
}

}
return 0;
}

kat
New poster
Posts: 3
Joined: Thu May 30, 2013 6:53 pm

Re: 10656 - Maximum Sum (II)

Post by kat »

Please Check this input/output:

Code: Select all

6
3 4 0 3 4 5
5
1 0 0 0 2
3
0 0 0
4
0 0 1 2

Code: Select all

3 4 3 4 5
1 2
0
1 2

Post Reply

Return to “Volume 106 (10600-10699)”