PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000086. Số mũi tên ít nhất để làm vỡ bóng bay (Minimum Number of Arrows to Burst Balloons)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Số mũi tên ít nhất để làm vỡ bóng bay (Minimum Number of Arrows to Burst Balloons)
Minimum Number of Arrows to Burst Balloons
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
There are balloons, balloon spanning the closed horizontal interval . An arrow fired vertically at real coordinate bursts every balloon whose interval contains . Find the minimum number of arrows to burst all balloons.
Input
The first line contains . Each of the following lines contains integer endpoints .
Output
Print the minimum number of arrows.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
4
10 16
2 8
1 6
7 12
Output
2
Explanation
An arrow at bursts balloons and . Another at bursts and . The first and third listed intervals are disjoint, so one arrow cannot suffice.