10656  Maximum Sum (II)
Moderator: Board moderators
defn of subsequence...
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.
 from mathworld
So, in the above example 2 5 is a subsequence of the given sequence.
asd
i got PE..can someone help me give me the sample input and output...
this is my code :
thanks..
this is my code :
Code: Select all
got accepted..

 New poster
 Posts: 37
 Joined: Wed Oct 03, 2007 10:42 am
Code: Select all
//remove
Last edited by alamgir kabir on Wed Nov 14, 2007 3:06 pm, edited 2 times in total.
Check the set very carefully.
Input:
Output:
Hope you get accepted.
Input:
Code: Select all
6
1
0
3
4
0
1
0
Code: Select all
1 3 4 1
Ami ekhono shopno dekhi...
HomePage
HomePage

 New poster
 Posts: 37
 Joined: Wed Oct 03, 2007 10:42 am
I do not consider this case.
Now I have acc it.
Thanks a lot Jan. I am greatful to u.
Thanks for helping me.
I hope u wil help me in future.
Now I have acc it.
Thanks a lot Jan. I am greatful to u.
Code: Select all
//code removed
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.
Ami ekhono shopno dekhi...
HomePage
HomePage

 Experienced poster
 Posts: 103
 Joined: Tue Mar 25, 2008 11:00 pm
 Location: IUTOIC, DHAKA, BANGLADESH
 Contact:
Re: 10656  Maximum Sum (II)getting PE
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...............................
It is more tough to become a good person.
I am trying both...............................
Re: 10656  Maximum Sum (II)
is there any trailing space??
i got 5 PE....
i got 5 PE....
Re: 10656  Maximum Sum (II)
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!=(n1))
printf(" ");
}
}
}
printf("\n");
}
return 0;
}
Re: 10656  Maximum Sum (II)
Very easy problem
As the numbers are all nonnegative, 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).
As the numbers are all nonnegative, 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
Re: 10656  Maximum Sum (II)
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;
}
#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)
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