#P1311. [NOIP 2011 提高组] 选择客栈
[NOIP 2011 提高组] 选择客栈
Description
Along the Lijiang River, there are distinctive inns, numbered from to in order of their locations. Each inn is decorated in one of hues (represented by integers ), and each inn has a coffee shop with its own minimum charge.
Two tourists are traveling together. They like the same hue but want to try two different inns, so they decide to stay at two inns with the same hue. At night, they plan to choose a coffee shop to have coffee. The coffee shop must be located between the two inns they stay at (including the inns themselves), and its minimum charge must not exceed .
They want to know the total number of ways to choose their accommodations such that they can find a coffee shop whose minimum charge is no more than yuan at night.
Input Format
There are lines.
The first line contains three integers , separated by single spaces, representing the number of inns, the number of hues, and the maximum acceptable minimum charge, respectively.
For the next lines, the -th line contains two integers, separated by a single space, denoting the hue of inn and the minimum charge of the coffee shop of inn .
Output Format
Output a single integer, the total number of valid accommodation choices.
5 2 3
0 5
1 3
0 2
1 4
1 5
3
Hint
Sample Explanation.

Since the two people must stay in inns with the same hue, all possible choices include: inns and , and , and , and . However, if they choose inns , the minimum charge of the coffee shops between inns and is , while their acceptable minimum charge is yuan, so this does not satisfy the requirement. Therefore, only the first choices are valid.
Constraints.
- For of the testdata, .
- For of the testdata, .
- For of the testdata, , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号