比赛场次 257
比赛名称 20150423
比赛状态 已结束比赛成绩
开始时间 2015-04-23 08:20:00
结束时间 2015-04-23 12:00:00
开放分组 全部用户
注释介绍
题目名称 马拉松2
输入输出 marathonb.in/out
时间限制 1000 ms (1 s)
内存限制 256 MiB
测试点数 15 简单对比
用户 结果 时间 内存 得分
Gravatarggwdwsbs AAAAAAAAAAAAAAA 0.171 s 1.29 MiB 100
Gravatar清羽 AAAAAAAAAAAAAAA 0.210 s 1.47 MiB 100
GravatarAsm.Def AAAAAAAAAAAAAAA 0.229 s 2.22 MiB 100
Gravatarmikumikumi AAAAAAAAAAAAAAA 0.467 s 2.31 MiB 100
Gravatarcstdio AAAAAAAAAAAAAAA 1.152 s 3.29 MiB 100
GravatarSatoshi AAWTTTTTTTTTTTT 12.002 s 1.28 MiB 13
GravatarRa-xp AWWWWWWWWWWWWWW 0.019 s 1.33 MiB 6
Gravatarfyb AWWWWWWWWWWWWWW 0.329 s 1.25 MiB 6
GravatarDijkstra AWWWWWWWWWWWWWW 3.828 s 2.24 MiB 6
Gravatarslyrabbit RRRRRRRRRRRRRRR 0.012 s 2.98 MiB 0
Gravatarwolf. EWWWWWWWWWWWWWW 0.213 s 0.25 MiB 0

马拉松2

★★   输入文件:marathonb.in   输出文件:marathonb.out   简单对比
时间限制:1 s   内存限制:256 MiB

【题目描述】


因为担心牛们的健康问题,FJ把为它们报了各种健身训练班。他最引以为傲的奶牛Bessie加入了一个长跑训练班,它期待自己经过训练之后能去参加马拉松比赛,赛场离FJ的牧场不远,需要穿过镇子。

马拉松场地由N(3 <= N <= 500)个检查站组成,选手需要按顺序经过这N个检查站,1号检查站为起点,N号检查站为终点,按规定Bessie也必须这样做,但是这个懒丫头决定偷个懒,它要跳过不超过K(K < N)个检查站以缩短赛程。不过,它还算有节制,不会跳过起点和终点,毕竟这样做显得太不尊重举办方了。

请帮Bessie计算一下,如果要跳过不超过K个检查站的话,它的最小行程是多少。

由于赛场是一块划分成网格的空地,站与站之间距离的计算方法是:如果两个检查站的坐标分别为(x1,y1)和(x2,y2),则它们之间的距离为|x1-x2|+|y1-y2|。


【输入格式】


第一行有两个整数,即N和K;

接下来有N行,每行有两个空格隔开的整数,x和y,表示一个检查站的坐标。检查站给出的顺序正是比赛时要求依次经过的顺序。注意跑步的路线有可能跟自己有若干次的交叉,也就是说会有一些检查站设在同一个位置,当Bessie决定跳过一个这样的检查站时,不意味着它要把设在这个点的检查站全都跳过。


【输出格式】

输出Bessie跳过不超过K个检查站后的最小行程数。

【样例输入】

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

【样例输出】

4

【提示】


样例解释:

跳过(8, 3)和(10, -5)两个点,得到最小行程为4.


【来源】



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 N checkpoints (3 <= N <= 500) to be

visited in sequence, where checkpoint 1 is the starting location and

checkpoint N 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 K checkpoints (K < N) in order to shorten her

total journey.  She cannot skip checkpoints 1 or N, 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 K checkpoints.  

Since the course is set in a downtown area with a grid of streets, the

distance between two checkpoints at locations (x1, y1) and (x2, y2) is

given by |x1-x2| + |y1-y2|.

INPUT:

The first line gives the values of N and K.

The next N lines each contain two space-separated integers, x and y,

representing a checkpoint (-1000 <= x <= 1000, -1000 <= y <= 1000).

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.

SAMPLE INPUT:

5 2

0 0

8 3

1 1

10 -5

2 2

OUTPUT:

Output the minimum distance that Bessie can run by skipping up to K

checkpoints.  In the sample case shown here, skipping the checkpoints

at (8, 3) and (10, -5) leads to the minimum total distance of 4.

SAMPLE OUTPUT:

4