Условия:
N intervals were colored on the number axis. We know the coordinate of the left and the right ends of each of these intervals (Li and Ri). Find the sum of the lengths of parts of the number axis, colored evenly in a single layer.
Use merge sort algorithm for sorting.
Пример:
Sample Input:
3
1 4
7 8
2 5
Sample Output:
3
Не понимаю, почему в примере ответ = 3. - IMHO, в один слой окрашены: 1, 5, 7 и 8, что в итоге = 4
М.б. загадка кроется в “evenly”, но логики пока не вижу…
