| AlgoChief Sprint Round 3 |
|---|
| Finished |
Sanjay is focusing on proposing questions. He wants to ensure that he and his soulmate are as far apart as possible on a 1D line. He needs your help to solve this problem optimally.
On a 1D line, two people are at Sanjay $$$(x_1)$$$ and his soulmate $$$(x_2)$$$ with $$$x_1 \lt x_2$$$.
Initially you have $$$n$$$ pairs $$$(l, r)$$$ such that $$$l \leq r$$$, $$$l \leq x_2$$$, and $$$x_1 \leq r$$$.
For each pair, you can perform:
Additionally, exactly once, you must perform both operations (1) and (2) on the same pair. For the remaining pairs, you must choose to perform either operation (1) or (2).
Your task is to find the maximum possible value of $$$x_2 - x_1$$$ after performing the operations optimally, ensuring that Sanjay and his soulmate are as far apart as possible.
2 2 2 9 1 8 3 7 3 10 60 11 58 12 59 13 59
5 47
| Name |
|---|


