시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB21150.000%

문제

The local Santa Claus needs help! He has realized that he cannot afford to give every child a present any longer, so he needs your help to select those lucky children that will get a present. He has made a record for each child containing the child’s level of excitement and frustration when getting or not getting a present, and now he wants a program that ensures that maximum total satisfaction is reached while preventing the total expenses to exceed his upper limit. The total satisfaction is defined as the sum of all excitements for those children that get presents, minus the sum of frustrations for the others.

입력

First line: n — the number of children (integer less or equal 1000), and p (integer less or equal 1000) — the expense limit.

Next n lines: 3 integers: price, excitement level and frustration level for each child. You can assume that all the prices, and excitement and frustration levels are nonnegative integers.

출력

First line: Total satisfaction. Second line: A string of n zeroes and ones — 0 means that this child does not get a present, 1 means that s/he gets a present.

예제 입력 1

5 10
4 2 5
3 8 4
6 3 1
7 7 2
1 4 6

예제 출력 1

11
11001