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 ...
随机推荐
- golang import all 类似python import * 效果
import "io/ioutil" func main() { content, err = iotuil.ReadFile("somefile.txt") ...
- yrzl-cloud
- selenium3 + python - expected_conditions判断元素
expected_conditions 类 title_is: 判断当前页面的title是否完全等于(==)预期字符串,返回布尔值 title_contains : 判断当前页面的title是否包含预 ...
- python 实现线程之间的通信
前言:因为GIL的限制,python的线程是无法真正意义上并行的.相对于异步编程,其性能可以说不是一个等量级的.为什么我们还要学习多线程编程呢,虽然说异步编程好处多,但编程也较为复杂,逻辑不容易理解, ...
- POJ 3264 线段树 ST
题意:给你一个数列,从中挑一段,问你这段数的最大值减最小值是多少. 思路:线段树. // by Sirius_Ren #include <cstdio> #include <algo ...
- ACM_来自不给标题的菜鸟出题组(巴什博弈+素数判定)
来自不给标题的菜鸟出题组 Time Limit: 2000/1000ms (Java/Others) Problem Description: 大B和小b合作出一道程序设计月赛的题,他们的想法是给定一 ...
- A - Diverse Team
Problem description There are n students in a school class, the rating of the i-th student on Codeho ...
- SQLServer2008 使用BCP导入导出表数据
--先开启cmdshell EXEC sp_configure 'show advanced options', 1 GO RECONFIGURE GO EXEC sp_configure 'xp_c ...
- rabbit channel参数
channel.exchangeDeclare() channel.ExchangeDeclare(string exchange: "cjlTest",string type: ...
- Vue2-Editor 使用
Vue-Editor底层采取的是quill.js,而quill.js采用的是html5的新属性classList,所以版本低于ie10会报错“无法获取未定义或 null 引用的属性‘confirm’” ...