Intervals
Time limit1sMemory limit128 MB
Given n integer intervals each needing at least c_i chosen points inside it, find the smallest set of integers satisfying all requirements.
- Level
Hard8 of 10
- Topics
- Greedy, Sorting, Prefix sum, Intervals
- Solved
- No attempts yet
Problem
You are given closed integer intervals together with integers .
Write a program that:
- reads the number of intervals , the two endpoints of each interval, and the integers from standard input,
- computes the minimum size of a set of integers that shares at least common elements with the interval for every ,
- writes that value to standard output.
In other words, minimize subject to for every .
Input
The first line contains the number of intervals .
Each of the next lines describes one interval. The -th line contains three integers , , and separated by single spaces, with and .
Output
Output a single integer: the minimum size of a set that shares at least elements with the interval for every .