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 ;
- }
Codeforces Round #375 (Div. 2) - A的更多相关文章
- Codeforces Round #375 (Div. 2) - D
题目链接:http://codeforces.com/contest/723/problem/D 题意:给定n*m小大的字符矩阵.'*'表示陆地,'.'表示水域.然后湖的定义是:如果水域完全被陆地包围 ...
- Codeforces Round #375 (Div. 2) - C
题目链接:http://codeforces.com/contest/723/problem/C 题意:给定长度为n的一个序列.还有一个m.现在可以改变序列的一些数.使得序列里面数字[1,m]出现次数 ...
- Codeforces Round #375 (Div. 2) - B
题目链接:http://codeforces.com/contest/723/problem/B 题意:给定一个字符串.只包含_,大小写字母,左右括号(保证不会出现括号里面套括号的情况),_分隔开单词 ...
- Codeforces Round #375 (Div. 2) F. st-Spanning Tree 生成树
F. st-Spanning Tree 题目连接: http://codeforces.com/contest/723/problem/F Description You are given an u ...
- Codeforces Round #375 (Div. 2) E. One-Way Reform 欧拉路径
E. One-Way Reform 题目连接: http://codeforces.com/contest/723/problem/E Description There are n cities a ...
- Codeforces Round #375 (Div. 2) D. Lakes in Berland 贪心
D. Lakes in Berland 题目连接: http://codeforces.com/contest/723/problem/D Description The map of Berland ...
- Codeforces Round #375 (Div. 2) B. Text Document Analysis 模拟
B. Text Document Analysis 题目连接: http://codeforces.com/contest/723/problem/B Description Modern text ...
- Codeforces Round #375 (Div. 2) A. The New Year: Meeting Friends 水题
A. The New Year: Meeting Friends 题目连接: http://codeforces.com/contest/723/problem/A Description There ...
- Codeforces Round #375 (Div. 2) Polycarp at the Radio 优先队列模拟题 + 贪心
http://codeforces.com/contest/723/problem/C 题目是给出一个序列 a[i]表示第i个歌曲是第a[i]个人演唱,现在选出前m个人,记b[j]表示第j个人演唱歌曲 ...
随机推荐
- Session原理浅析
什么是Sesson? 简单说就是一个会话级的cookie,外加服务器端内存中一组散列表. 当你关闭浏览器的时候,这个cookie将消失. 这个cookie不写在磁盘上,而是存在于浏览器缓存. 关于Se ...
- 【leetcode】 Longest Valid Parentheses (hard)★
Given a string containing just the characters '(' and ')', find the length of the longest valid (wel ...
- 微信支付官方.net版之坑你没商量
最近开始弄支付这块,先是支付宝手机网站支付,也是坑了我许久,不过还好,问题不大. 让我们看看微信支付有多少坑 微信商户平台,你们知道么(我前天才知道,别笑我) 登录地址:https://mch.wei ...
- Android笔记:获取屏幕信息
像素密度(dpi) float xdpi = getResources().getDisplayMetrics().xdpi;float ydpi = getResources().getDispla ...
- Python 文件处理
文件夹: 得到当前工作目录,即当前Python脚本工作的目录路径: os.getcwd() 返回指定目录下的所有文件和目录名:os.listdir() 函数用来删除一个文件:os.remove() 删 ...
- grep -v 排除多人字符串
# egrep -v '^$|^#' /etc/httpd/conf/httpd.conf # grep -v '^$\|^#' /etc/httpd/conf/httpd.conf
- Weblogic监控指标
http://blog.csdn.net/a_dreaming_fish/article/details/50592042
- PHP实现执行定时任务的几种思路详解
转:https://segmentfault.com/a/1190000002955509 PHP本身是没有定时功能的,PHP也不能多线程.PHP的定时任务功能必须通过和其他工具结合才能实现,例如Wo ...
- JavaWeb学习之JSTL自定义标签库的使用、JSTL自定义函数库(7)
一.自定义标签,步骤 * 确定需求 * <my:date /> 输出当前系统的时间 yyyy-MM-dd hh:mm:ss:SSS * 编写Java类 新建包名:com.yxl.tag,新 ...
- Delphi线程简介---Create及其参数、Resume、Suspend
TThread在Classes单元里的声明如下 type TThread = class private FHandle: THandle; FThreadID: THandle; FTerminat ...