Scheduling
Time limit1sMemory limit256 MB
Decide whether n preemptible tasks with release times, deadlines, and processing times can be scheduled on m identical processors within their windows.
- Level
Hard8 of 10
- Topics
- Greedy, Sorting, Intervals, Implementation
- Solved
- No attempts yet
Problem
Byteasar celebrates his thirteenth birthday. One of the gifts from his parents is a brand new computer. He hastily unwrapped his gift and started reading the computer's manual. It turned out that the computer has processors. Byteasar is very happy, because at last he is able to execute many tasks in parallel!
He swiftly prepared a list of tasks (numbered through ) that he plans to execute on his new computer. A processor can execute no more than a single task at once. Task takes seconds to complete, and it is forbidden to start its execution less than seconds since the gift's unwrapping or complete it later than seconds after the gift's unwrapping. Every task's execution can be interrupted arbitrarily many times and it can be moved between different processors. However, it cannot be executed on two or more processors simultaneously. Moving a task between processors takes negligible time. Is it possible to schedule the execution of tasks so that each task is executed and completed within its timeframe? In other words, does there exist a strategy of starting, interrupting and moving tasks between processors that would allow Byteasar achieve his goal?
Input
The first line of the input contains two integers and () denoting the number of tasks and the number of processors, respectively. The following lines describe Byteasar's tasks. The -th of them contains a description of task : three integers , and () denoting the beginning and the end of the time interval when it is allowed to execute the -th task (expressed in seconds since the gift's unwrapping), and the time it takes to complete this task, respectively.
Output
If it is possible to complete all the tasks within their respective timeframes, print YES. Otherwise, print NO.