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

6221번 - The Bale Tower 다국어

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

문제

Always bored with cud-chewing, the cows have invented a new game. One cow retrieves a set of N (3 <= N <= 20) hay bales from the shed each of which is one unit high. Each bale also has some unique width and unique breadth.

A second cow tries to choose a set of bales to make the tallest stack of bales in which each bale can be placed only on a bale whose own width and breadth are smaller than the width and breadth of the bale below. Bales can not be rotated to interchange the width and breadth.

Help the cows determine the highest achievable tower that can be legally built form a set of bales.

입력

  • Line 1: A single integer, N
  • Lines 2..N+1: Each line describes a bale with two space-separated integers,respectively the width and breadth

출력

  • Line 1: The height of the tallest possible tower that can legally be built from the bales.

제한

예제 입력 1

6
6 9
10 12
9 11
8 10
7 8
5 3

예제 출력 1

5

힌트

These bales can be stacked for a total height of 5:

10 12
9 11
8 10
6 9
5 3

another stacking exists, too

출처

Olympiad > USA Computing Olympiad > 2006-2007 Season > USACO January 2007 Contest > Bronze 3번

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

출처

대학교 대회

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

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