You are not logged in. Please login at to post your questions!


need help in spoj problem on segment tree GSS1

Can someone help me with this problem from spoj. I am getting wrong answer on TC9 . Here is my code . I am using long long int and fast I/O but still getting WA. Thanks in advance:)

This question is marked "community wiki".

asked 19 May '18, 02:08

pavitra_ag's gravatar image

accept rate: 5%

wikified 19 May '18, 17:17

Your code is all right except that struct g.

In struct g everything should be -infinty (or MIN, a number less than MIN(a[i]))

For example, consider an array with all elements as negative, and node such that

. (mid, end) is completely out of range (l, r)

. (start, mid) exactly (or partially) overlaps with (l, r)

Then in your merging t.sufsum=max(p2.sufsum,p2.sum+p1.sufsum); which means t.sufsum = 0; which is not the case as it's < 0:

You can have a look at my code (though it's almost similar to yours)


answered 19 May '18, 17:56

pshishod2645's gravatar image

accept rate: 13%

HOLY MOLY. Thanks man this helped me a lot wasted about 4 hours. Finally AC

(19 May '18, 20:21) pavitra_ag4★
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 19 May '18, 02:08

question was seen: 139 times

last updated: 19 May '18, 20:21