cf723a The New Year: Meeting Friends
There are three friend living on the straight line Ox in Lineland. The first friend lives at the point x1, the second friend lives at the pointx2, and the third friend lives at the point x3. They plan to celebrate the New Year together, so they need to meet at one point. What is the minimum total distance they have to travel in order to meet at some point and celebrate the New Year?
It's guaranteed that the optimal answer is always integer.
The first line of the input contains three distinct integers x1, x2 and x3 (1 ≤ x1, x2, x3 ≤ 100) — the coordinates of the houses of the first, the second and the third friends respectively.
Print one integer — the minimum total distance the friends need to travel in order to meet together.
7 1 4
6
30 20 10
20
In the first sample, friends should meet at the point 4. Thus, the first friend has to travel the distance of 3 (from the point 7 to the point 4), the second friend also has to travel the distance of 3 (from the point 1 to the point 4), while the third friend should not go anywhere because he lives at the point 4.
/*
大意:三个sb,住在一条数轴上,要到一个点集合,问最小总距离
这个其实就是中位数啦,无论向左还是向右都不会更优
*/
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n[],ans;
int main(){
cin>>n[]>>n[]>>n[];
sort(n+,n+);
ans = abs(n[]-n[]) + abs(n[]-n[]);
cout<<ans;
return ;
}
cf723a The New Year: Meeting Friends的更多相关文章
- [LeetCode] Best Meeting Point 最佳开会地点
A group of two or more people wants to meet and minimize the total travel distance. You are given a ...
- [LeetCode] Meeting Rooms II 会议室之二
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si ...
- [LeetCode] Meeting Rooms 会议室
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si ...
- Scrum Meeting 20161205
本周Sprint Master 史少帅 一. 会议概要 作为一个新的sprint的开端,本次scrum meeting总结了每个人过去以来的工作,并明确了下一步的计划,具体如下: 工作总结: · 陈双 ...
- Beta阶段第十次Scrum Meeting
情况简述 BETA阶段第十次Scrum Meeting 敏捷开发起始时间 2017/1/4 00:00 敏捷开发终止时间 2017/1/5 00:00 会议基本内容摘要 deadline到来 参与讨论 ...
- Beta阶段第九次Scrum Meeting
情况简述 BETA阶段第九次Scrum Meeting 敏捷开发起始时间 2017/1/2 00:00 敏捷开发终止时间 2017/1/3 00:00 会议基本内容摘要 deadline临近 参与讨论 ...
- Beta阶段第八次Scrum Meeting
情况简述 BETA阶段第八次Scrum Meeting 敏捷开发起始时间 2016/12/21 00:00 敏捷开发终止时间 2016/12/22 00:00 会议基本内容摘要 deadline临近 ...
- Beta阶段第七次Scrum Meeting
Beta阶段第七次Scrum Meeting 情况简述 BETA阶段第七次Scrum Meeting 敏捷开发起始时间 2016/12/20 00:00 敏捷开发终止时间 2016/12/21 00: ...
- Beta阶段第六次Scrum Meeting
情况简述 BETA阶段第六次Scrum Meeting 敏捷开发起始时间 2016/12/16 00:00 敏捷开发终止时间 2016/12/17 00:00 会议基本内容摘要 平稳推进 参与讨论人员 ...
随机推荐
- Ubuntu 部署Postgresql
安装组件 客户端安装 sudo apt-get install postgresql-client 服务器安装 sudo apt-get install postgresql postgresql-c ...
- 在github上建立自己的网站
学了前端小半年,如今写了个自己的网页想要去应聘,却发现部署很麻烦,部署到阿里云之类,买域名啊啥的还要收费,说贵也不贵,但我就是傲娇~ google一下了解到Github有一个Github pages的 ...
- PAT 1032. 挖掘机技术哪家强(20)
为了用事实说明挖掘机技术到底哪家强,PAT组织了一场挖掘机技能大赛.现请你根据比赛结果统计出技术最强的那个学校. 输入格式: 输入在第1行给出不超过105的正整数N,即参赛人数.随后N行,每行给出一位 ...
- Specific sleep staging features in EEG
Source: MedScape Overview NREM and REM occur in alternating cycles, each lasting approximately 90-10 ...
- MVC4 自定义错误页面(转)
一.概述 MVC4框架自带了定义错误页,该页面位于Shared/Error,该页面能够显示系统未能捕获的异常,如何才能使用该页面: 二.使用步骤: 1.配置WebConfig文件,在System.We ...
- 用table做网页,设置了border为1px怎么还是觉得很粗?
设置边框重叠 border-collapse:collapse; /*边框重叠*/ 例: <table width="700" style="border-col ...
- 基于jquery的bootstrap在线文本编辑器插件Summernote
Summernote是一个基于jquery的bootstrap超级简单WYSIWYG在线编辑器.Summernote非常的轻量级,大小只有30KB,支持Safari,Chrome,Firefox.Op ...
- greenDao:操作数据库的开源框架
greenDAO: Android ORM for your SQLite database 1. greenDao库获取 英文标题借鉴的是greendrobot官网介绍greenDao时给出的Tit ...
- 为什么 "auto a = 1;" 在C语言中可以编译通过?
参照:这里 这让我想起之前看的一部书, int i; 其实是等价与 auto int i; 表示为局部变量 这应该与static是相对的吧?
- 利用Microsoft.Practices.Unity的拦截技术,实现.NET中的AOP
1.记住这个单词的意思:Interception(拦截) 2.首先说一下原理和背景 原理:所谓的AOP就是面向切面编程,这里不多说,百度搜索. 目的:个人认为是为了解耦,部分代码跟业务代码分离,业务代 ...