포럼
문제 ICPC00251

A. Altruistic Amphibians

설명

A set of frogs have accidentally fallen to the bottom of a large pit. Their only means of escaping the pit is to jump out of it. Each frog \(i\) is described by three parameters \((l_i,w_i,h_i)\) where \(l_i\) is its leap capacity, \(w_i\) its weight, and \(h_i\) its height. The leap capacity specifies how high that frog can jump. If a frog's leap capacity is strictly larger than the depth of the pit, the frog can directly escape the pit. However, these frogs are altruistic. Rather than selfishly saving themselves and leaving the frogs with too limited leap capacity behind, they collectively aim to save as many of them from the pit as possible.

The frogs realize that if a frog \(A\) climbs up on the back of frog \(B\) before it jumps, the first frog \(A\) stands a better chance of escaping the pit: it can escape if \(h_B+l_A\) is strictly larger than the depth of the pit.

Furthermore, if frog \(B\) carrying frog \(A\) on its back climbs up on the back of frog \(C\), the situation is even better for frog \(A\): it can now escape the pit if \(h_C+h_B+l_A\) is strictly larger than the depth of the pit.

The frogs can build even higher piles of frogs this way, the only restriction is that no frog may carry other frogs of weight in total amounting to its own weight or heavier. Once a pile has been used to allow a frog to escape, the frogs in the pile jump back to the bottom of the pit and they can then form a new pile (possibly consisting of a different set of frogs). The question is simply how many frogs can escape the pit assuming they collaborate to maximize this number?

제약
입력 형식

The first line of input contains two integers \(n\) and \(d\) (\(1 \le n \leq 100\,000\), \(1 \le d \le 10^8\)), where \(n\) is the number of frogs and \(d\) is the depth of the pit in µm. Then follow \(n\) lines each containing three integers \(l, w, h\) (\(1 \le l, w, h \le 10^8\)), representing a frog with leap capacity \(l\) µm, weight \(w\) µg, and height \(h\) µm. The sum of all frogs' weights is at most \(10^8\) µg.

출력 형식

Output the maximum number of frogs that can escape the pit.

예제 1
입력
3 19
15 5 3
12 4 4
20 10 5
출력
3
예제 2
입력
3 19
14 5 3
12 4 4
20 10 5
출력
2
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC NCPC 2018

평가 및 의견

A. Altruistic Amphibians

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

A. Altruistic Amphibians

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8