×

# need help in pointing out my mistake>

 2 Its simple. Use double not float because you need precision for values as large as ${2}*{10}^{8}$. See this TC- Input 5 100000000 100000000 100000000 100000000 99999999 1 2 4 Your Output 200000000.0 Correct Output 199999999.0  Determining what data type to use is the most fundamental concept which requires 100% accuracy. Be careful next time. Also, next time, please give 2 minutes into indenting your code or adding proper comments. Its really painful for eyes to see an un-indented and uncommented code. Please think of the person going through your code to help you. answered 09 Dec '17, 19:25 13.9k●1●12●40 accept rate: 19% thanks a lot!! And I definitely will try to indend my code from next time.. (09 Dec '17, 20:04) Thank you dear :) (09 Dec '17, 21:51)
 0 It is a basic segment tree problem with an insight. View Content answered 09 Dec '17, 16:58 3.4k●12●36 accept rate: 24% this is exactly what I have done. it would be helpful if you could point out the mistake in my code (09 Dec '17, 17:01) i guess you should use ceil function for ceil( (max(L,R) - min(L,R))/2) (09 Dec '17, 17:04) http://www.geeksforgeeks.org/min-max-range-queries-array/ Also, refer this implementation of Segment tree for min-max queries (09 Dec '17, 17:06) but i did max((max(l,r)+min(l,r))/2,min(l,r)+max( max(0, L-1), max(R+1, N-1))) which is basically the same thing and hence does not require ceil function (09 Dec '17, 17:21) Wait.. I'm solving it myself.. (09 Dec '17, 17:27) it would be nice if u could point out error in my code,instead of solving it your self:) (09 Dec '17, 17:48) Your segment tree is working fine.. (09 Dec '17, 17:54) Can't figure out what's wrong with your code... :( My code with same approach gives AC https://www.codechef.com/viewsolution/16521589 (09 Dec '17, 18:07) thanks for your help.. found the solution to my problem (09 Dec '17, 20:07) No problem. Although @vijju123 is the one to be thanked. (09 Dec '17, 22:07) showing 5 of 10 show all
 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:

×408
×282
×17

question asked: 09 Dec '17, 16:40

question was seen: 259 times

last updated: 09 Dec '17, 22:07