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

16423번 - To Tell the Truth 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB105827580.645%

문제

There are n people in a room, each of whom always tells the truth, or always lies. Each of them makes a statement of the form: “Some number between a and b (inclusive) of us are telling the truth.” What is the maximum number of truth-tellers in the room?

입력

Each input will consist of a single test case. Note that your program may be run multiple times on different inputs.

Each test case will begin with a line containing an integer n (1 ≤ n ≤ 1,000) which is the number of people in the room.

Each of the next n lines will have two space-separated integers, a and b (0 ≤ a ≤ b ≤ n). Each line represents the statement of one person that “Some number between a and b (inclusive) of us are telling the truth.”

출력

Output a single integer, which is the largest possible number of truth-tellers, or -1 if the statements are inconsistent.

제한

예제 입력 1

3
1 1
2 3
2 2

예제 출력 1

2

예제 입력 2

8
0 1
1 7
4 8
3 7
1 2
4 5
3 7
1 8

예제 출력 2

-1

힌트

출처

ICPC > Regionals > North America > Southeast USA Regional > 2018 Southeast USA Regional Programming Contest > Division 1 K번

ICPC > Regionals > North America > Southeast USA Regional > 2018 Southeast USA Regional Programming Contest > Division 2 K번

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

출처

대학교 대회

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

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