#P6163. [Cnoi2020] 领域极限
[Cnoi2020] 领域极限
Description
Cirno has integers, denoted as .
For each number , there is a constraint pair .
Cirno wants to know:
$$\min_{\forall t, a_t \in [l_t,r_t]}\big\{\sum_{i=1}^{n}\sum_{j=1}^{n}\left| a_i - a_j \right|\big\}$$Input Format
The first line contains an integer .
The next lines each contain a constraint pair .
Output Format
One line containing an integer, which is the answer.
3
1 2
2 3
3 4
4
8
39 42
53 55
51 52
46 47
52 54
33 38
2 7
32 34
910
Hint
Sample 1 Explanation
When , the answer reaches its minimum.
Constraints and Notes
"This problem uses bundled testdata."
- Subtask 1 ( ): , and .
- Subtask 2 ( ): .
- Subtask 3 ( ): .
- Subtask 4 ( ): .
For of the testdata: , , and the answer is within .
Translated by ChatGPT 5
京公网安备 11011102002149号