CF164C.Machine Programming

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

One remarkable day company "X" received kk 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 nn tasks, for each of them we know the start time of its execution sis_{i} , the duration of its execution tit_{i} , and the company profit from its completion cic_{i} . 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 sis_{i} to si+ti1s_{i}+t_{i}-1 , inclusive, and it cannot switch to another task.

You are required to select a set of tasks which can be done with these kk machines, and which will bring the maximum total profit.

输入格式

The first line contains two integer numbers nn and kk ( 1<=n<=10001<=n<=1000 , 1<=k<=501<=k<=50 ) — the numbers of tasks and machines, correspondingly.

The next nn lines contain space-separated groups of three integers si,ti,cis_{i},t_{i},c_{i} ( 1<=si,ti<=1091<=s_{i},t_{i}<=10^{9} , 1<=ci<=1061<=c_{i}<=10^{6} ), sis_{i} is the time where they start executing the ii -th task, tit_{i} is the duration of the ii -th task and cic_{i} is the profit of its execution.

输出格式

Print nn integers x1,x2,...,xnx_{1},x_{2},...,x_{n} . Number xix_{i} should equal 11 , if task ii should be completed and otherwise it should equal 00 .

If there are several optimal solutions, print any of them.

输入输出样例

  • 输入#1

    3 1
    2 7 5
    1 3 3
    4 1 3
    

    输出#1

    0 1 1
    
  • 输入#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).

首页