#3892. [Usaco2014 Dec]Marathon

[Usaco2014 Dec]Marathon

题目描述

Unhappy with the poor health of his cows, Farmer John enrolls them in an assortment of different physical fitness activities. His prize cow Bessie is enrolled in a running class, where she is eventually expected to run a marathon through the downtown area of the city near Farmer John's farm! The marathon course consists of nn checkpoints to be visited in sequence, where checkpoint 11 is the starting location and checkpoint nn is the finish. Bessie is supposed to visit all of these checkpoints one by one, but being the lazy cow she is, she decides that she will skip up to kk checkpoints in order to shorten her total journey. She cannot skip checkpoints 11 or nn, however, since that would be too noticeable. Please help Bessie find the minimum distance that she has to run if she can skip up to kk checkpoints. Since the course is set in a downtown area with a grid of streets, the distance between two checkpoints at locations (x1,y1)(x_1, y_1) and (x2,y2)(x_2,y_2) is given by x1x2+y1y2\left|x1-x2\right|+\left|y1-y2\right|.

在二维平面上有 nn 个点,从 (x1,y1)(x_1, y_1)(x2,y2)(x_2,y_2) 的代价为 x1x2+y1y2\left|x1-x2\right|+\left|y1-y2\right|

求从 11 号点出发,按从 11nn 的顺序依次到达每个点的最小总代价。

你有 kk 次机会可以跳过某个点,不允许跳过 11 号点或 nn 号点。

输入格式

The first line gives the values of nn and kk. The next nn lines each contain two space-separated integers, xix_i and yiy_i, representing a checkpoint. The checkpoints are given in the order that they must be visited. Note that the course might cross over itself several times, with several checkpoints occurring at the same physical location. When Bessie skips such a checkpoint, she only skips one instance of the checkpoint -- she does not skip every checkpoint occurring at the same location.

输出格式

Output the minimum distance that Bessie can run by skipping up to kk checkpoints.

5 2
0 0
8 3
1 1
10 -5
2 2

4

样例说明

In the sample case shown here, skipping the checkpoints at (8,3)(8, 3) and (10,5)(10, -5) leads to the minimum total distance of 44.

数据规模与约定

对于 100%100\% 的数据,3n5003 \le n \le 500k<nk<n103xi,yi103-10^3 \le x_i,y_i \le 10^3

题目来源

Silver