Interval

아직 제출이 없습니다시간 제한3초메모리 제한1024 MB

문제

There are nn closed intervals \[l_1,r_1],\[l_2,r_2],,\[l_n,r_n]\[l\_1,r\_1], \[l\_2,r\_2], \ldots, \[l\_n,r\_n]. You need to choose mm intervals such that the mm intervals have nonempty intersection. In other words, there exists some xx such that for any selected interval \[l_i,r_i]\[l\_i,r\_i], l_ixr_il\_i \leq x \leq r\_i.

The cost of selecting a collection of mm intervals with nonempty intersection is the maximum length of the mm intervals minus the minimum length of the mm intervals. The length of interval \[l_i,r_i]\[l\_i, r\_i] is r_il_ir\_i - l\_i.

Compute the minimum cost of choosing mm intervals with nonempty intersection. If this is impossible, output -1.

입력

The first line consists of two positive integers n,mn,m separated by a single space where nn is the total number of intervals and mm is the number of intervals we are going to choose. It is guaranteed that 1mn1 \leq m \leq n.

In the following nn lines, each line consists of two integers l_i,r_il\_i,r\_i separated by a space denoting the left and right endpoints of an interval.

출력

Output a line with an integer denoting the minimum cost.

제한

Test casen=n =m=m=l_i,r_il\_i,r\_i
12020990l_ir_i1000 \leq l\_i \leq r\_i \leq 100
21010
3199199330l_ir_i100,0000 \leq l\_i \leq r\_i \leq 100\\,000
4200200
51,0001\\,00022
62,0002\\,000
719919960600l_ir_i5,0000 \leq l\_i \leq r\_i \leq 5\\,000
82002005050
90l_ir_i1090 \leq l\_i \leq r\_i \leq 10^9
101,9991\\,9995005000l_ir_i5,0000 \leq l\_i \leq r\_i \leq 5\\,000
112,0002\\,000400400
125005000l_ir_i1090 \leq l\_i \leq r\_i \leq 10^9
1330,00030\\,0002,0002\\,0000l_ir_i100,0000 \leq l\_i \leq r\_i \leq 100\\,000
1440,00040\\,0001,0001\\,000
1550,00050\\,00015,00015\\,000
16100,000100\\,0002000020000
17200,000200\\,0000l_ir_i1090 \leq l\_i \leq r\_i \leq 10^9
18300,000300\\,00050,00050\\,000
19400,000400\\,00090,00090\\,000
20500,000500\\,000200,000200\\,000