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

8155번 - Postering 다국어

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

문제

All the buildings in the east district of Byteburg were built in accordance with the old arbitecture: they stand next to each other with no spacing inbetween. Together they form a very long chain of buildings of diverse height, extending from east to west.

The mayor of Byteburg, Byteasar, has decided to have the north face of the chain covered with posters. Byteasar ponders over the minimum number of posters sufficient to cover the whole north face. The posters have rectangular shape with vertical and horizontal sides. They cannot overlap, but may touch each other, i.e. have common points on the sides. Every poster has to entirely adjoin the walls of certain buildings and the whole surface of the north face has to be covered.

Write a programme that:

  • reads the description of buildings from the standard input,
  • determines the minimum number of posters needed to entirely cover their north faces,
  • writes out the outcome to the standard output.

입력

The first line of the standard input contains one integer n (1 ≤ n ≤ 250,000), denoting the number of buildings the chain comprises of. Each of the following n lines contains two integers di and wi (1 ≤ di,wi ≤ 1,000,000,000), separated by a single space, denoting respectively the length and height of the ith building in the row.

출력

The first and only line of the standard output should contain one integer, the minimum number of rectangular posters that suffice to cover the north faces of the buildings.

제한

예제 입력 1

5
1 2
1 3
2 2
2 5
1 4

예제 출력 1

4

힌트

For the sample input

For the sample output

The figures show the north face of the buildings chain. The second figure shows an exemplary covering of the face with four posters.

출처

Olympiad > Polish Olympiad in Informatics > POI 2007/2008 > Stage 1 3번

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

출처

대학교 대회

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

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