Page 3 of 4

defn of subsequence...

Posted: Tue Dec 28, 2004 10:58 am
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.

Posted: Fri Dec 31, 2004 3:46 am
by CodeMaker
hmm, thanks... looks like I have problems in basic :oops:

Posted: Wed Jul 05, 2006 12:09 pm
by Stummer
Thanks to Adrian Kuegel :wink: !!! At last I got Accepted!

can anyone tell why WA

Posted: Sun Jul 22, 2007 8:10 pm
by bishop
why this is wa
is there any critical way to solve
this

Code: Select all



asd

Posted: Thu Aug 23, 2007 9:25 am
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..

Posted: Fri Nov 09, 2007 3:45 pm
by alamgir kabir

Code: Select all

//remove
Thanks Jan for helping me.

Posted: Fri Nov 09, 2007 9:29 pm
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.

Posted: Wed Nov 14, 2007 3:04 pm
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.

Posted: Wed Nov 14, 2007 8:03 pm
by Jan
Try the case.

Input:

Code: Select all

3
0
0
0
0
Output:

Code: Select all

0
Hope it helps.

Re: 10656 - Maximum Sum (II)getting PE

Posted: Wed Apr 02, 2008 4:20 pm
by kbr_iut
now AC, code removed

Re: 10656 - Maximum Sum (II)

Posted: Tue Mar 22, 2011 10:48 am
by asif.mist
is there any trailing space??
i got 5 PE....

Re: 10656 - Maximum Sum (II)

Posted: Fri Apr 29, 2011 4:51 pm
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;
}

Re: 10656 - Maximum Sum (II)

Posted: Thu Jun 30, 2011 4:56 pm
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).

Re: 10656 - Maximum Sum (II)

Posted: Mon Aug 22, 2011 8:36 pm
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;
}

Re: 10656 - Maximum Sum (II)

Posted: Sat Jan 18, 2014 4:28 pm
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