Need help in Pishty and Triangles

i am solving pishty and triangles pishty and triangles , i made a segment tree and do as it is in editorial ,taking the most 45 numbers and finding the triangle with max perimeter but getting only 5 points , help my solution