#GD0000092. Phản ví dụ: chọn đoạn ngắn nhất (Shortest Interval Counterexample)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Phản ví dụ: chọn đoạn ngắn nhất (Shortest Interval Counterexample)
Shortest Interval Counterexample
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given half-open jobs , no two overlapping jobs can both be chosen. Strategy A repeatedly chooses the remaining shortest-duration job, breaking ties by smaller start and then smaller original index, and eliminates every job overlapping it. Strategy B chooses the maximum possible number of compatible jobs. Output both counts. Touching at endpoints does not count as overlap.
Input
The first line contains . The next lines contain for job .
Output
Print two integers: the number chosen by strategy A and the maximum number chosen by strategy B.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
3
0 3
2 4
3 6
Output
1 2
Explanation
Durations are . Strategy A first picks , which overlaps both others, yielding only job. Strategy B picks and , which meet at an endpoint, so the optimum is .