PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BF0000033. Đoạn nguyên và hai điểm (Integer Intervals)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đoạn nguyên và hai điểm (Integer Intervals)
Integer Intervals
Source: POJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given closed integer intervals , each with at least two integers, choose a minimum-size set containing at least two chosen integers in every interval.
Input
First line , followed by pairs .
Output
Print the minimum number of chosen integers.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
3
1 3
2 5
4 6
Output
4
Explanation
For instance covers each given interval with at least two selected integers. The first interval needs two integers not available in the last interval, so at least four are necessary.