Logo
(追記) (追記ここまで)

6722번 - Christmas presents 다국어

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

문제

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

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > Nordic Collegiate Programming Contest > NCPC 2001 B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /