#x1030. CF164C Machine Programming
CF164C Machine Programming
Machine Programming
题面翻译
题目描述:
有一家公司有 台机器,并且有 个任务需要完成,对于每一个任务我们知道它的开始时间 和持续时间 ,并且完成这个任务后这家公司可以获利 。每一台机器都可以处理任何任务,但不能同时处理多个任务,在处理某个任务时也不能切换到其他任务(即当某个机器处理任务 时,在 至 时间段内就只能处理这个任务)。你需要选择一些任务来完成,使得总利润最大。
输入格式:
第一行为两个整数 , 。 和 分别代表任务数量和机器数量。
接下来 行每行三个整数 ,含义如描述。
输出格式:
输出 个数字 ,以空格相隔。数字 为 或 , 代表选择任务 , 代表不选择。 如果有多个选择方案,输出任何一个即可。
by lyh
题目描述
One remarkable day company "X" received machines. And they were not simple machines, they were mechanical programmers! This was the last unsuccessful step before switching to android programmers, but that's another story.
The company has now tasks, for each of them we know the start time of its execution , the duration of its execution , and the company profit from its completion . Any machine can perform any task, exactly one at a time. If a machine has started to perform the task, it is busy at all moments of time from to , inclusive, and it cannot switch to another task.
You are required to select a set of tasks which can be done with these machines, and which will bring the maximum total profit.
输入格式
The first line contains two integer numbers and ( , ) — the numbers of tasks and machines, correspondingly.
The next lines contain space-separated groups of three integers ( , ), is the time where they start executing the -th task, is the duration of the -th task and is the profit of its execution.
输出格式
Print integers . Number should equal , if task should be completed and otherwise it should equal .
If there are several optimal solutions, print any of them.
样例 #1
样例输入 #1
3 1
2 7 5
1 3 3
4 1 3
样例输出 #1
0 1 1
样例 #2
样例输入 #2
5 2
1 5 4
1 4 5
1 3 2
4 1 2
5 6 1
样例输出 #2
1 1 0 0 1
提示
In the first sample the tasks need to be executed at moments of time 2 ... 8, 1 ... 3 and 4 ... 4, correspondingly. The first task overlaps with the second and the third ones, so we can execute either task one (profit 5) or tasks two and three (profit 6).