Codeforces Round #375 (Div. 2) - A

时间:2023-03-10 02:53:28
Codeforces Round #375 (Div. 2) - A

题目链接:http://codeforces.com/contest/723/problem/A

题意:在一维坐标下有3个人(坐标点)。他们想选一个点使得他们3个到这个点的距离之和最小。

思路:水题。显然对这3个坐标点排序。则选的点一定是中间那个点最优。

#define _CRT_SECURE_NO_DEPRECATE
#include<stdio.h>
#include<string.h>
#include<cstring>
#include<algorithm>
#include<queue>
#include<math.h>
#include<time.h>
#include<vector>
#include<iostream>
using namespace std;
typedef long long int LL;
const int INF = 0x3f3f3f3f;
const int MAXN = + ;
int x[];
int main(){
while (~scanf("%d%d%d", &x[], &x[], &x[])){
sort(x, x + );
printf("%d\n", (x[] - x[]) + (x[] - x[]));
}
return ;
}