PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BF0000034. Dãy số nguyên theo các đoạn (Sequence)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Dãy số nguyên theo các đoạn (Sequence)
Sequence
Source: Luogu
Version: Phuoc Hung OJ Extended
Problem Statement
Find the minimum length of a sequence of distinct integers such that at least elements fall inside each given closed interval .
Input
First line , then triples .
Output
Print the minimum sequence length.
Subtasks
- Subtask 1 (20 points): $1\le N\le20; 0\le L_i\le R_i\le30; 1\le C_i\le R_i-L_i+1$.
- Subtask 2 (30 points): $1\le N\le200; 0\le L_i\le R_i\le300; 1\le C_i\le R_i-L_i+1$.
- Subtask 3 (50 points): $1\le N\le1000; 0\le L_i\le R_i\le1000; 1\le C_i\le R_i-L_i+1$.
Examples
Input
4
4 5 1
6 10 3
7 10 3
5 6 1
Output
4
Explanation
The set satisfies every interval requirement: the intervals and contain three selected numbers; and each contain one. Thus an answer of is possible and optimal.