#P2352. 队爷的新书
队爷的新书
Description
Duiye is about to publish a new book to record his glorious problem-solving journey.
There are publishers interested in this book. Each is willing to pay a fee to obtain the publishing rights, where each publisher has its own and .
Now Duiye wants you to find a value that maximizes his total revenue. Every publisher with will pay .
Input Format
The first line contains an integer .
The next lines each contain two integers and , which are the acceptable payment range of the -th publisher.
Output Format
Output a single integer ans, the maximum total payment.
4
1 3
2 4
3 5
4 7
12
Hint
Sample Explanation:
When , there are publishers who will pay, which is maximal.
Constraints:
- For of the testdata, .
- For of the testdata, $1 \leq n \leq 1000, 1 \leq Min_{pay}, Max_{pay} \leq 10^6$.
- For of the testdata, $1 \leq n \leq 100000, 1 \leq Min_{pay}, Max_{pay} \leq 10^9$.
Translated by ChatGPT 5
京公网安备 11011102002149号