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

34291번 - Club Pizza 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB78423068.182%

문제

When Blaster first started at Mines, he joined as many different extracurricular clubs as he could. He loves getting involved on campus, and he also loves that many clubs provide free pizza! Unfortunately, now he is in too many clubs, and some of the meetings overlap. Additionally, if he eats too much pizza, then he will be too full to do any more activities.

Blaster still wants to attend as many clubs as he can. Each club meeting is only one hour long, but some club meetings might be at the same time as each other. Different clubs give different amounts of pizza, so he needs to decide which meetings to go to in order to maximize the amount of clubs he goes to before getting full of pizza.

If Blaster chooses optimally, how many clubs will he be able to attend?

입력

The first line of the input consists of two integers $n,c$ (1ドル \leq n \leq 10^3, 0 \leq c \leq 10^6$)---the number of clubs and the number of pizza slices Blaster can eat before being full, respectively.

The $i$-th line of the following $n$ lines contains two integers $t_i, p_i$ (0ドル \leq t_i < 24, 0 \leq p_i \leq 10^6$)---the hour of the day that the $i$-th club meets at and the number of pizza slices he will eat at the $i$-th meeting, respectively.

출력

Output a single integer, the number of clubs that Blaster can attend.

제한

예제 입력 1

3 6
18 3
19 2
20 1

예제 출력 1

3

In sample input 1, there are three clubs at 18:00, 19:00, and 20:00 that give 3ドル,ドル 2ドル,ドル and 1ドル$ slices of pizza, respectively. Blaster can eat 6ドル$ slices of pizza, so he can attend all three clubs.

예제 입력 2

3 4
18 3
19 2
20 1

예제 출력 2

2

예제 입력 3

4 12
17 3
17 5
19 4
19 10

예제 출력 3

2

In sample input 3, Blaster can either visit clubs 1ドル$ and 3ドル$ or visit clubs 2ドル$ and 3ドル$.

힌트

출처

School > CS@Mines > CS@Mines HSPC 2025 K번

  • 문제를 만든 사람: Jayden Pahukula
(追記) (追記ここまで)

출처

대학교 대회

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

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