Take a look at these two submissions
The only difference between these two was that the data types for variables $$$n, k$$$, and vectors $$$a, hld1, hld2$$$. Instead of having them be long doubles, they were int. Now, look at the execution time! The difference is huge! The one with the ints has around 12 times better time than the one with long doubles! I knew that working with floats led to higher constant factors but didn't know that it would be that big.
You're not just using floats btw
You're using long double which is four times bigger than int.
I also suspect that the difference is in particular related to the long double division