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 »

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 »

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 »

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 »

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 »

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 »

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)

Post by lighted »

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 »

Accepted :D thank you :D
Post Reply

Return to “Volume 106 (10600-10699)”