#P1314. [NOIP 2011 提高组] 聪明的质监员
[NOIP 2011 提高组] 聪明的质监员
Description
Xiao T is a quality inspector in charge of checking a batch of ores. There are ores, numbered from to . Each ore has a weight and a value . The inspection process is:
- Given intervals .
- Choose a parameter .
- For an interval , compute the inspection value :
Here is the ore index, and is the indicator function: it returns if condition is true, and otherwise.
The overall inspection result for this batch is the sum of inspection values over all intervals, i.e., .
If the overall inspection result differs too much from the given standard value , another batch must be inspected. Xiao T wants to avoid extra work, so he will adjust the parameter to make the result as close to as possible, i.e., minimize . Please compute this minimum value.
Input Format
The first line contains three integers , denoting the number of ores, the number of intervals, and the standard value.
The next lines each contain two integers separated by a space. The -th line gives the weight and value of ore .
The next lines describe the intervals. Each line contains two integers separated by a space. The -th line gives the endpoints and of interval . Note: different intervals may coincide or overlap.
Output Format
Output a single integer, the minimum value required.
5 3 15
1 5
2 5
3 5
4 5
5 5
1 5
2 4
3 3
10
Hint
Explanation for the sample input and output:
When is , the inspection values on the three intervals are , , , so the overall result is . The minimum difference from the standard value is .
Constraints:
- For of the testdata, .
- For of the testdata, .
- For of the testdata, .
- For of the testdata, .
- For of the testdata, , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号