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

17980번 - Alehouse 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB25191578.947%

문제

Making friends can seem impossible, but going to the alehouse makes it easy — it is actually the only way to make friendships. Luckily, the alehouse is extremely good at its task: if two people are inside simultaneously, they instantly become friends. People even become friends if they meet each other in the door as one leaves and one enters the alehouse!

In Consistentville, each of its n residents goes to the alehouse exactly once each week, and always during the same milliseconds as the week before. This is convenient for everyone, since then nobody needs to befriend new people all the time, which can be quite exhausting.

You are contemplating a move to Consistentville in order to adopt their well-ordered lifestyle, and have decided that you want as many friends as possible. However, you don’t actually enjoy ale that much, so you decide to limit your weekly visit at the alehouse to at most k milliseconds. What is the maximum number of friends you can get?

입력

The first line of input contains two positive integers n (1 ≤ n ≤ 100 000), and k (0 ≤ k < 604 800 000). The next n lines describe at which millisecond each of the original residents of Consistentville enters and leaves the alehouse every week. Specifically, the ith line consists of two integers ai and bi (0 ≤ ai ≤ bi < 604 800 000) indicating that the ith resident enters the alehouse at millisecond ai and leaves the alehouse at millisecond bi each week.

출력

A single integer, the maximum number of friends you can get.

제한

예제 입력 1

6 2
0 2
1 8
5 9
2 4
7 8
10 10

예제 출력 1

4

힌트

출처

Contest > Bergen Open > Bergen Open 2019 A번

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

출처

대학교 대회

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

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