×

# need help in spoj problem on segment tree GSS1

 0 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 69●6 accept rate: 5%

 1 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 825●1●13 accept rate: 13% HOLY MOLY. Thanks man this helped me a lot wasted about 4 hours. Finally AC (19 May '18, 20:21)
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• 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:

×1,768
×1,138
×21

question asked: 19 May '18, 02:08

question was seen: 139 times

last updated: 19 May '18, 20:21