Codeforces 595C - Warrior and Archer
思路:设最后答案的区间为[l,r],那么r-l等于n/2,因为在(l,r)中的点都是其中一个人挖掉的,[0,l)和(r,n]中的点是另一个人挖掉的,两者相等。
代码:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a)) const int INF=0x7f7f7f7f;
const int N=2e5+; int a[N]; int main()
{
ios::sync_with_stdio(false);
cin.tie();
int n;
cin>>n;
for(int i=;i<n;i++)
cin>>a[i]; sort(a,a+n);
int ans=INF;
for(int i=;i<n;i++)
{
if(i+n/>=n)break;
ans=min(ans,a[i+n/]-a[i]);
} cout<<ans<<endl;
return ;
}
Codeforces 595C - Warrior and Archer的更多相关文章
- Codeforces 594A - Warrior and Archer
题目大意:给你在一条线上的n(偶数)个点,mike和alice 开始禁点,他们轮流开始,直到最后只剩下两个点, mike希望剩下的两个点距离尽可能小,alice希望剩下的两个点距离尽可能大,他们都采用 ...
- Codeforces Round #330 (Div. 1) A. Warrior and Archer 贪心 数学
A. Warrior and Archer Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/594 ...
- http://codeforces.com/problemset/problem/594/A
A. Warrior and Archer time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- cf Round 594
A.Warrior and Archer(思维) 战士一定会ban掉当前边缘的位置.而战士和射手就会选择剩下的最远的两点.我们让剩下的最远的两点最近就达到了均衡.于是我们枚举战士ban掉的边缘,ban ...
- 【转】Qt之JSON保存与读取
简述 许多游戏提供保存功能,使得玩家在游戏中的进度可以被保存,并在以后再玩的时候进行加载.保存游戏的过程通常涉及将每个游戏对象的成员变量序列化为文件.要实现这个功能,可以采取许多格式,其中之一就是 J ...
- Unity技巧集合
地址:http://blog.csdn.net/stalendp/article/details/17114135 这篇文章将收集unity的相关技巧,会不断地更新内容. 1)保存运行中的状态 uni ...
- Codeforces Round #185 (Div. 2) B. Archer 水题
B. Archer Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/312/problem/B D ...
- CodeForces 312B Archer
Archer Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Original ...
- 【CodeForces 312B】BUPT 2015 newbie practice #3A Archer
题 SmallR is an archer. SmallR is taking a match of archer with Zanoes. They try to shoot in the targ ...
随机推荐
- liferay常用api总结
liferay之笑傲江湖学习笔记<一> 我们大家都知道,想要在一项技术上过硬,你需要付出汗水的,需要闭门修炼,每一个成功的人,都是那种耐得住寂寞的人,好了闲话少说.开始学习之旅 在life ...
- redis和memcached相关
应该选择哪一种缓存机制 redis相较于memcached更加年轻,功能更加强大. 对小型静态数据进行缓存处理,最具代表性的例子就是HTML代码片段.使用memcached所消耗内存更少. 其他情况下 ...
- zw版【转发·台湾nvp系列Delphi例程】HALCON SigmaImage1
zw版[转发·台湾nvp系列Delphi例程]HALCON SigmaImage1 procedure TForm1.Button1Click(Sender: TObject);var img, im ...
- BP神经网络的Java实现(转载)
神经网络的计算过程 神经网络结构如下图所示,最左边的是输入层,最右边的是输出层,中间是多个隐含层,隐含层和输出层的每个神经节点,都是由上一层节点乘以其权重累加得到,标上“+1”的圆圈为截距项b,对输入 ...
- tomcat和jetty区别
参见:https://www.cnblogs.com/fengli9998/p/7247559.html 1. Jetty更轻量级.这是相对Tomcat而言的. 由于Tomcat除了遵循Java Se ...
- ajax请求为异步操作时,返回的数据不会被并列函数执行
ajax请求为异步操作时,返回的数据不会被并列函数执行
- Linux基础命令---e2fsck
ex2fsck 检查ext2.ext3.ext4文件系统,如果系统已经挂载了,那么不建议去检查,因为这样是不安全的.此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.SUSE.op ...
- Unity3D关于VR的Demo(一)
https://blog.csdn.net/qq_15807167/article/details/52048998?locationNum=8&fps=1 阅读数:9716 最近有点忙,只有 ...
- 20145322 Exp5 Adobe阅读器漏洞攻击
20145322 Exp5 Adobe阅读器漏洞攻击 实验过程 IP:kali:192.168.1.102 windowsxp :192.168.1.119 msfconsole进入控制台 使用命令为 ...
- c/c++ 动态申请数组(转载)
转载:http://blog.csdn.net/hondely/article/details/6779887 转载:http://bbs.csdn.net/topics/390721031 转载:h ...