8942: 涞坊路
内存限制:128 MB
时间限制:1.000 S
提交:3
解决:0
评测方式:文本比较
命题人:
题目描述
涞坊路是一条长 米的道路,道路上的坐标范围从 到 ,路上有 座房子,第 座房子建在坐标为 的地方,其中住了 人。
松江 1843 路公交车要在这条路上建一个公交站,市政府希望让最多的人得到方便,因此希望所有的每一个的居民,从家到车站的距离的总和最短。
公交站应该建在哪里呢?
输入
第一行输入 、。
接下来 行,每行两个整数 和 。
输出
一个整数,最小的每个人从家到车站的距离的总和。
样例输入 复制
100 3
20 3
50 2
70 1
样例输出 复制
110
提示
样例解释 1
当建在坐标 的时候,所有人距离车站的距离总和为 。