#K73132. Find Common Range
Find Common Range
Find Common Range
You are given a list of ranges (intervals) represented by pairs of integers \(L\) and \(R\). Your task is to compute the common intersection range of all the given intervals.
The common range is determined by the formulas:
\(L_{common} = \max_{i=1}^{n} L_i\) and \(R_{common} = \min_{i=1}^{n} R_i\).
If \(L_{common} \le R_{common}\), then the common range exists and is \([L_{common}, R_{common}]\). Otherwise, there is no common range.
If no ranges are provided, output No common range
.
inputFormat
The first line of input contains an integer \(n\), the number of ranges.
Each of the next \(n\) lines contains two space-separated integers \(L\) and \(R\) representing a range.
If \(n = 0\), it indicates that there are no ranges.
outputFormat
If a common range exists, output two space-separated integers representing \(L_{common}\) and \(R_{common}\). Otherwise, output the string No common range
.
3
1 5
2 6
3 4
3 4