You would like to make a schedule for your weekend. The weekend consists of two days, Saturday and Sunday, of $$$24\cdot60\cdot60\cdot1000={86\,400\,000}$$$ milliseconds each. You have a list of $$$n$$$ tasks for Saturday and $$$m$$$ tasks for Sunday, and your primary objective is to complete all tasks.
Every task has a start time $$$s$$$, a deadline $$$e$$$, and a duration $$$d$$$, each given in milliseconds. At any moment in time, you are only able to work on a single task. However, you may distribute the work of any task over several periods of time, so long as the total time you work on any task is equal to its duration.
At any moment you are not working on any task, you will sleep. For reasons having to do with your circadian rhythm, you would like to synchronize your sleep schedules on Saturday and Sunday as much as possible. Your secondary objective is thus to maximize the total time overlap of scheduled sleep between Saturday and Sunday.
A schedule for the weekend with perfectly synchronized 8 hours of sleep on each day. The input consists of:
If it is impossible to complete all the tasks, output impossible. Otherwise, output the maximum number of milliseconds of overlap of scheduled sleep between Saturday and Sunday.
1 1 40000000 60000000 15000000 50000000 70000000 15000000
66400000
2 1 40000000 60000000 15000000 40000000 60000000 15000000 50000000 70000000 15000000
impossible
3 2 25000000 55000000 10000000 35000000 45000000 5000000 60000000 75000000 10000000 30000000 40000000 10000000 45000000 65000000 15000000
56400000
| Name |
|---|


