Codeforces 1249D2 - Too Many Segments
Xem dạng PDF
Gửi bài giải
Điểm:
5,00 (OI)
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
512M
Input:
stdin
Output:
stdout
Nguồn bài:
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
Reference: Codeforces 1249D2 — Too Many Segments
You are given ~n~ closed segments on an integer coordinate line. Segment ~i~ is:
~[l_i, r_i]~
and covers every integer point ~x~ satisfying:
~l_i \le x \le r_i~
An integer point is considered overloaded if it is covered by more than ~k~ remaining segments.
Remove the minimum possible number of segments so that no integer point is overloaded.
Input
- The first line contains two integers ~n~ and ~k~.
- The following ~n~ lines contain the segment endpoints: ~l_i~ and ~r_i~.
Output
- On the first line, print one integer ~m~: the minimum number of segments to remove.
- On the second line, print ~m~ distinct indices of the removed segments in any order. (When ~m = 0~, the second line may be empty.)
Constraints
- ~1 \le k \le n \le 2 \times 10^5~
- ~1 \le l_i \le r_i \le 2 \times 10^5~
Example 1
Input:
7 2
11 11
9 11
7 8
8 9
7 8
9 11
7 9
Output:
3
4 6 7
Bình luận