## 10656 - Maximum Sum (II)

Moderator: Board moderators

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 10656 - Maximum Sum (II)

Check input and AC output for thousands of problems on uDebug!

sejan
New poster
Posts: 6
Joined: Sun Nov 16, 2014 8:32 pm

### Re: 10656 - Maximum Sum (II)

Code: Select all

``````CODE REMOVED
``````
Last edited by sejan on Wed Nov 19, 2014 7:23 pm, edited 2 times in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 10656 - Maximum Sum (II)

Input:

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``````
AC output:

Code: Select all

``````3 4 3 4 5
1 2
0
1 2
``````
Check input and AC output for thousands of problems on uDebug!

sejan
New poster
Posts: 6
Joined: Sun Nov 16, 2014 8:32 pm

### Re: 10656 - Maximum Sum (II)

outputs matched but still PE

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 10656 - Maximum Sum (II)

Don't print a space at the end of a line.
Check input and AC output for thousands of problems on uDebug!

sejan
New poster
Posts: 6
Joined: Sun Nov 16, 2014 8:32 pm

### Re: 10656 - Maximum Sum (II)

brianfry713 wrote:Don't print a space at the end of a line.
tried but then it gives "wrong answer"

lighted
Guru
Posts: 587
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

### Re: 10656 - Maximum Sum (II)

Try it again. One way to do it

Code: Select all

``````int t = 0;
for(i=0; i<tc; i++)
{
if(a[i]!=0)
printf("%s%d", t++ ? " " : "", a[i]);
}
printf("\n");
``````
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

sejan
New poster
Posts: 6
Joined: Sun Nov 16, 2014 8:32 pm

### Re: 10656 - Maximum Sum (II)

Accepted thank you