시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB1410660.000%

문제

It's that time of the year! Time again for Eurovision (and FPC)! Although, there is something rather special about this edition. In an unexpected turn of events, Delft was chosen to host Eurovision in the Aula. As you might expect, all tickets were sold out in a matter of seconds: students from all over Delft's faculties are eager to attend such a special event. Naturally, their enthusiasm is sparked by the same question: "What's the longest time a contestant has to sing without breathing, given that they breathe optimally?"

A song is divided into $n$ musical segments, where the $i$th musical segment has pitch intensity $a_i$ and is $b_i$ seconds in length. Each contestant sings these musical segments consecutively, with no pause in between, but will take some deep breaths at key moments (consider the time it takes to breathe negligible). To maintain a pleasing rhythm of music, performers only breathe immediately after a local minimum in pitch intensity (i.e., after a musical segment $i$ where $a_{i-1} > a_i < a_{i+1}, 1 < i < n$) and do not take more than $k$ breaths in total.

Note:

  • Eurovision contestants have an inclination towards algorithmic thinking, and therefore, they all breathe optimally: within the constraints, the longest time between two breaths is as short as possible.
  • Naturally, a singer will breathe right before starting to sing and immediately after finishing, so these two breaths do NOT count towards the total number of breaths.

입력

The input consists of:

  • One line containing two integers: $n$ ($1\leq n\leq 10^4$), the number of musical segments in the song, and $k$ ($0\leq k < n$), the maximum number of breaths that can be taken while performing the song.
  • $n$ lines containing two integers each, $a_i$ and $b_i$ ($1 \leq a_i, b_i \leq 10^9$), the pitch and length (in seconds) of the $i$th musical segment.

출력

Output the longest time (in seconds) between two breaths, for an optimal performance of the song.

예제 입력 1

6 1
1 1
2 1
1 1
2 1
1 1
2 1

예제 출력 1

3

예제 입력 2

9 2
2 1
1 1
2 1
1 1
2 1
1 1
2 1
1 1
2 1

예제 출력 2

4