Please Check the solution to SPOJ GSS1 problem.

I read other posts about this and tried almost all test cases given on SPOJ Toolkit and it seems to work fine, but when I submit on SPOJ, it says wrong answer on judge 9.

Please Check.

Solution is here

3 Likes

3

-1 -1 -1
1

1 2

check this test case
Your ans is 0, should be -1

otherwise your code seems ok

4 Likes

@neilit1992 thanks for the response, I fixed the code, it now works on this case but still shows WA on spoj.

Please Check line 53, I updated there.

Here’s The code

Thanks.

3 Likes

I checked it with @neilit1992 s code, tried inputs from spojtoolkit and even printed all the nodes of segment trees of both the programs (mine and @neilit1992 ) and they were exactly same.

Still no Luck :frowning:

Thats my


[1]

If someone can provide some more boundary cases (except those on spoj toolkit) that would be really helpful.

Thanks

  [1]: http://ideone.com/x52qvD
2 Likes

Check Line 58, shouldn’t you return best sum as minimum value?

Please Check, I guess the following code should be there:

  return (node)				
	{min, 
		min, 
		min, 
		min
	};
2 Likes

@shraeyas the problem is in this line

pr.best = maxfun(maxfun(left.rsum+right.total, left.total + right.lsum),maxfun(left.best, right.best));

It should be corrected to

pr.best = maxfun(left.rsum + right.lsum, maxfun(left.best, right.best));

However this will still give you TLE since you are using a map. Access is faster on an array than a map, so use a large enough array instead and you should get AC :slight_smile:

7 Likes

First of all, apologies @shraeyas for random suspension you went through since last 4 hours.
This being a long story, please bear with me.

@shraeyas was suspended earlier on 3rd March due to spamming activity on discussion forum for 15 days i.e. till 18th March. But we recently found out bug in auto removal of suspension and got fixed today morning. After this all users who were temporary suspended, got their accounts back on discuss (including @shraeyas).

But, unfortunately that fix didn’t propagated to the new servers which were specially started before Alkhwarizm contest and had older code. Hence, his account was again visible as suspended from ~8:30PM. Thanks @shubham_genius, @neilit1992 and @meooow to bring it into notice, and new fix has been propagated properly.

(posing as answer, due to characters limit in comment)

3 Likes

nc0ibW - Online C++0x Compiler & Debugging Tool - Ideone.com this is my working code, please try to debug

3 Likes

Thank You :slight_smile:

2 Likes

it’ll give error, I tried that, there is some bug in the code and its difficult to debug!

1 Like

Ohhkay, BTW why has the author been suspended?

1 Like

I’ve no idea, why people get suspended

1 Like

I’m curious too, why was @shraeyas suspended?

1 Like

I actually mailed codechef regarding this bug on bugs@codechef.com 2 days before.

3 Likes

@meooow Don’t know how to express my thanks to you.

Was really frustated with this one.

Thank you so much @meooow and @neilit1992

:smiley:

3 Likes

Oh, didn’t came across your email, but got similar info from another user. Anyway, the bug is finally removed from auto removal of suspension. Welcome back to discuss. :smiley:

And refrain spamming in future… :stuck_out_tongue:

2 Likes

Sure… will stick to that

Thanks :slight_smile:

1 Like

So that’s the case! I was quite confused when I saw it. It also did not show which admin suspended it and why. Well, this explains things!

1 Like