I'm reviewing algorithms, and I've come across this problem. At first, it seemed like an interval scheduling problem to me, but now I think it is a dynamic programming problem. I'm not sure how to solve this. I'd appreciate if someone could show me a solution.

---

Suppose you are an employee. Your boss has sent you to attend a conference. The conference lasts $n$ minutes. In the course of this conference, there are $m$ talks you can attend. Your boss has ordered that you must attend talks for the entirety of the conference, i.e. all $n$ minutes. 

The talks have two quantified properties: a tuple (*start-minute*, *end-minute*) and *stressfulness*, a variable fixed cost incurred whenever you enter a talk. You seek to minimize the total stressfulness of the conference. Moreover, you are free to **leave or enter a talk** whenever you please. Find an efficient algorithm to pick the talks to attend.

---

The last part is critically important: it means that you can choose overlapping intervals to satisfy the problem. 

In case it is not fully clear, here is an example for what the input data might look like. Let $L$ be the conference length, and $T$ the time-interval of each talk, and $S$ the stressfulness of each talk.

$L = 600$  

Talk 1: $T=(0,400), S=15$  

Talk 2: $T=(0,50), S=2$  

Talk 3: $T=(50,300),S=8$  

Talk 4: $T=(250,450),S=10$  

Talk 5: $T=(400,500),S=4$  

Talk 6: $T=(450,600),S=5$

You can choose Talk 1, Talk 5, and Talk 6 totalling $S=24$. The next-best alternative would be Talk 2, Talk 3, Talk 4, and Talk 6 at a total cost of $S=25$. Consequently, you choose to attend Talk 1, Talk 5, and Talk 6.