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


SPREAD2 sigsegv error

why was this solution showing a sigsegv error when I used a prefix sum array to solve the problem? Any help would be appreciated. Thanks in advance.

asked 17 Oct '18, 10:29

eaugene's gravatar image

accept rate: 20%

The only reason i can see is int overflow just make array presum i.e. a and variable i long long. The overflow is causing your variable i to go less than 0 which will make -ve array indexing and hence RE.I guess you will get the idea :)


answered 17 Oct '18, 12:14

ram_24's gravatar image

accept rate: 35%


Thanks @ram_24 . A silly mistake costed me 19 penalty attempts.

(17 Oct '18, 15:35) eaugene4★

Yes, the problem occurs at line 21 in your code. If the input is large and value of 'i' gets above INT_MAX, 'i' overflows for next iteration and the indexing gets disturbed ! Hence SIGSEGV.


answered 17 Oct '18, 12:54

ayush_0101's gravatar image

accept rate: 28%

Thank You @ayush_0101 .

(17 Oct '18, 15:36) eaugene4★
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: 17 Oct '18, 10:29

question was seen: 522 times

last updated: 17 Oct '18, 15:36