I have been trying to solve this question on kattis(Avoiding Airports) since 7 months. I know the dp solution. Which is sort all flights by start time and then calculate total frustration of taking each flight.

{flight[i].s is start time of flight i and flight[i].e is end time of flight i}.

frustration of i'th flight f[i] = min(f[j]+(flight[i].s-flight[j].e)^2) for j < i . Many people then told me that you can make this faster by using convex hull trick. Where slope here is -2*flight[j].e and constant = dp[j]+flight[j].e^2 So for a particular flight with start time flight[i].s I have to find the best (slope,constant). But I don't know how to make the query because the slope/-2 < flight[i].s has to be satisfied. How can I still make queries. Most problems I took to learn CHT didn't have any conditions on the slope. If someone can give another example to some problem that would also help.