Even though i tried many times and even checked with the solutions, I’m getting wrong answer everytime. It’s working with simple test cases on codeblocks and ideone.

Here’s my code: http://ideone.com/FlTscZ

You need to sort the array which stores the areas. Then find the indices. You haven’t sorted them.

See here: http://www.codechef.com/viewsolution/2812458

The problem is with the precision of floating numbers in your code.I have declared all your intermediate variables long double instead of double and changed the code to http://ideone.com/KCCsia. It got accepted.

You could have used the formula

2A = |x1(y2-y3)+x2(y3-y1)+x3(y1-y2)|

to calculate the area.This does not involve calculation of lengths of triangle and thus no chance for any precision errors.

First of all dont do floating point comparison with >= and <=. Use variable called EPS to do comparisons. (Read this post on quora: http://www.quora.com/Competitive-Programming/What-are-the-things-that-one-needs-to-take-care-of-while-dealing-with-floating-point-calculations-in-competitive-programming-questions) .The link to the corrected solution is: http://www.codechef.com/viewsolution/2838730. And secondly always try to avoid floating point comparisons , like it can be done in this case. Use the formula of area in terms of coordinates of point dont calculate the sides.

thank you all for the solutions!!!was very helpful.

sorting is not needed in the question as we have only to find the max and min values of area.