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

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

Re: 10656 - Maximum Sum (II)

Post by brianfry713 » Mon Jan 20, 2014 11:35 pm

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)

Post by sejan » Mon Nov 17, 2014 9:36 pm

getting PE. please help

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)

Post by brianfry713 » Tue Nov 18, 2014 2:40 am

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)

Post by sejan » Tue Nov 18, 2014 7:34 am

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)

Post by brianfry713 » Tue Nov 18, 2014 9:54 pm

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)

Post by sejan » Wed Nov 19, 2014 3:47 pm

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

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

Re: 10656 - Maximum Sum (II)

Post by lighted » Wed Nov 19, 2014 5:22 pm

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)

Post by sejan » Wed Nov 19, 2014 7:24 pm

Accepted :D thank you :D

Post Reply

Return to “Volume 106 (10600-10699)”