PalForce's blog

By PalForce, history, 5 years ago, In English

Avoiding Airports

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.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By PalForce, history, 6 years ago, In English

Avoiding Airports How to solve avoiding airports. I wrote a shortest distance approach using dijkstra but gives TLE. How to avoid going in loops to catch some flight at a particular node that leads to the destination. Can someone give a solution to this problem.

Full text and comments »

  • Vote: I like it
  • +5
  • Vote: I do not like it