ACdream 1735 输油管道
输油管道
Problem Description
平面上有n个油井,现在要建立一条主干线,用来把所有的油井产出的原油都输送出去,主干线是平行于x轴的一条直线,每个油井通过一条支线把原油输送到主干线上,现在给定n个油井在平面上的坐标,那么应该把主干线建在什么地方才能让所有的支干线的总长度最小呢?

Input
Output
Sample Input
2
0 0
10 10
Sample Output
10
Source
Manager
#include <bits/stdc++.h>
using namespace std;
const int maxn = ;
typedef long long LL;
LL y[maxn],x;
int main(){
int n;
while(~scanf("%d",&n)){
for(int i = ; i < n; ++i)
scanf("%lld%lld",&x,y+i);
sort(y,y+n);
LL mid = y[(n-)>>],ret = ;
for(int i = ; i < n; ++i)
ret += abs(y[i] - mid);
printf("%lld\n",ret);
}
return ;
}
ACdream 1735 输油管道的更多相关文章
- acdream 1735 输油管道 贪心
输油管道 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acdream.info/problem?pid=1735 Description ...
- ACdream 1735 输油管道 (排序)
http://acdream.info/problem?pid=1735 官方题解:http://acdream.info/topic?tid=4246 因为主干线是平行于x轴的直线,那么跟x坐标其实 ...
- ACdream - 1735:输油管道
Time Limit: 2000/1000MS (Java/Others) Memory Limit: 262144/131072KB (Java/Others) Problem Descriptio ...
- acoj-1735 输油管道 【中位数】
题目链接:http://acdream.info/problem?pid=1735 输油管道 Time Limit: 2000/1000MS (Java/Others) Memory Limit: 2 ...
- ACdream 1214---矩阵连乘
ACdream 1214---矩阵连乘 Problem Description You might have noticed that there is the new fashion among r ...
- acdream.LCM Challenge(数学推导)
LCM Challenge Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Submit ...
- acdream.Triangles(数学推导)
Triangles Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Submit Stat ...
- acdream.A Very Easy Triangle Counting Game(数学推导)
A - A Very Easy Triangle Counting Game Time Limit:1000MS Memory Limit:64000KB 64bit IO Forma ...
- acdream.Bet(数学推导)
Bet Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Submit Status Pra ...
随机推荐
- 一张图告诉你Git的所有命令
- jsonArray和Java List对象互转,日期处理
List转jsonArray : // 格式化日期 JsonConfig jsonConfig = new JsonConfig(); DSHJsonDateValueProcessor dshJso ...
- 邪恶的C++
曾经看到一篇很有趣的文章,今天转载一下.抱歉的是没有找到最原始的版本,算是遗憾吧. ---------- 华丽的分割线 ---------- Linus曾经(2007年9月)在新闻组gmane.com ...
- matlab中s函数编写心得-转自水木
S函数是system Function的简称,用它来写自己的simulink模块.(够简单吧,^_^, 详细的概念介绍大伙看帮助吧)可以用matlab.C.C++.Fortran.Ada等语言来写, ...
- POJ 2728(最优比率生成树+01规划)
Dese ...
- 欧拉函数&&欧拉定理
定义和简单性质 欧拉函数在OI中是个非常重要的东西,不知道的话会吃大亏的. 欧拉函数用希腊字母φ表示,φ(N)表示N的欧拉函数. 对φ(N)的值,我们可以通俗地理解为小于N且与N互质的数的个数(包含1 ...
- KNN in c++
Pseudo Code of KNN We can implement a KNN model by following the below steps: Load the data Initiali ...
- 0503 php中for与foreach的区别
结论: foreach:只能用于数组和对象,如果是非索引数组,只可以用foreach. for:如果是索引数组,可以用for遍历. foreach循环结构是按照数组内部的指针去循环的,当 foreac ...
- selenium3 + python - gird分布式(转载)
本篇转自博客:上海-小T 转载链接:https://blog.csdn.net/real_tino/article/details/53467406 Selenium grid是用来分布式执行测试用例 ...
- Python 30 网络编程介绍
1.目标:编写一个C/S架构的软件 C/S:Client --------------- 基于网络 ------------------- Server B/S:Browser ---------- ...