P9697 [GDCPC 2023] Canvas
题目描述
有一个长度为 $n$ 的序列,一开始序列中的所有元素均为 $0$。另外还有 $m$ 个操作,其中第 $i$ 个操作会将序列中第 $l_i$ 个元素的值改为 $x_i$,以及将序列中第 $r_i$ 个元素的值改为 $y_i$。每个操作必须恰好执行一次。
求执行操作的最优顺序,使得所有操作执行完成后,序列中所有元素之和最大。
输入格式
无
输出格式
无
说明/提示
For the first sample test case, after performing operations $4, 1, 3, 2$ in order, the sequence becomes $\{2, 2, 2, 1\}$. The sum of all elements is $7$.
For the second sample test case, after performing operations $2, 1$ in order, the sequence becomes $\{2, 0, 2, 1\}$. The sum of all elements is $5$.