(N+1)-legged race

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

문제

You are a teacher of a class of SS students. The students are numbered from 11 to SS, and the ii-th student has athletic ability A_iA\_i and height H_iH\_i.

In an upcoming sports day your class is going to compete in a game called (N+1N+1)-legged race. In this race NN runners of a team line up in a row, connect their legs using ankle straps (more precisely, connect the first runner's right leg and the second runner's left leg, the second runner's right leg and the third runner's left leg, and so on), and run together toward a goal.

As the teacher of the class you have to choose NN students from your class as runners of the race and decide the order of these NN runners. Of course, each runner's athletic ability is one of the key factors of the strength of the team. However, you have noticed that if two adjacent runners have very different heights, it ends up losing the strength of the team. After all, if students of numbers r_1,,r_Nr\_1, \dots , r\_N line up in this order, the strength of this team is defined as follows.

  • _i=1NA_r_i_i=1N1H_r_iH_r_i+1\sum\_{i=1}^{N}{A\_{r\_i}} - \sum\_{i=1}^{N-1}{\left| H\_{r\_i} - H\_{r\_{i+1}}\right|}

Your task is to maximize the strength of the team.

입력

The input consists of a single test case of the following format.

SS NN

A_1A\_1 H_1H\_1

\vdots

A_SvA\_Sv H_S$

The first line contains two integers SS and NN (2S1052 ≤ S ≤ 10^5, 2Nmin(S,200)2 ≤ N ≤ \min{(S, 200)}), which represent the number of students in your class and the number of students that you have to choose from your class as runners. Each of the next SS lines contains two integers A_iA\_i and H_iH\_i (1A_i,H_i1091 ≤ A\_i, H\_i ≤ 10^9), which represent the athletic ability and height of the ii-th student in your class.

출력

Print the maximum strength of the team that you can accomplish.