【推导】Codeforces Round #424 (Div. 1, rated, based on VK Cup Finals) A. Office Keys
选择的钥匙一定是连续的,人和钥匙一定从左到右连续对应。
就枚举钥匙区间即可。
#include<cstdio>
#include<algorithm>
using namespace std;
int Abs(int x){
return x<0 ? (-x) : x;
}
int n,K,p,a[1010],ans=2147483647,b[2010];
int main(){
scanf("%d%d%d",&n,&K,&p);
for(int i=1;i<=n;++i){
scanf("%d",&a[i]);
}
for(int i=1;i<=K;++i){
scanf("%d",&b[i]);
}
sort(a+1,a+n+1);
sort(b+1,b+K+1);
for(int i=1;i<=K;++i){
if(i+n-1>K){
break;
}
int maxx=0;
for(int j=1,k=i;j<=n;++j,++k){
maxx=max(maxx,Abs(a[j]-b[k])+Abs(b[k]-p));
}
ans=min(ans,maxx);
}
printf("%d\n",ans);
return 0;
}
【推导】Codeforces Round #424 (Div. 1, rated, based on VK Cup Finals) A. Office Keys的更多相关文章
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) D. Office Keys time limit per test2 seconds 二分
D. Office Keys time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)
http://codeforces.com/contest/831 A. Unimodal Array time limit per test 1 second memory limit per te ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) A 水 B stl C stl D 暴力 E 树状数组
A. Unimodal Array time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem C (Codeforces 831C) - 暴力 - 二分法
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)A,B,C
A:链接:http://codeforces.com/contest/831/problem/A 解题思路: 从前往后分别统计递增,相等,递减序列的长度,如果最后长度和原序列长度相等那么就输出yes: ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem F (Codeforces 831F) - 数论 - 暴力
题目传送门 传送门I 传送门II 传送门III 题目大意 求一个满足$d\sum_{i = 1}^{n} \left \lceil \frac{a_i}{d} \right \rceil - \sum ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem D (Codeforces 831D) - 贪心 - 二分答案 - 动态规划
There are n people and k keys on a straight line. Every person wants to get to the office which is l ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem E (Codeforces 831E) - 线段树 - 树状数组
Vasily has a deck of cards consisting of n cards. There is an integer on each of the cards, this int ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem A - B
Array of integers is unimodal, if: it is strictly increasing in the beginning; after that it is cons ...
随机推荐
- 如何升级nodejs版本 安装n模块报错 npm ERR! notsup Unsupported platform
如何升级nodejs版本 首先安装n模块, 输入npm install -g n n模块专门用来管理nodejs的版本. 如果出现npm ERR! notsup Unsupported platfor ...
- jsp之jstl核心标签库
JSTL核心标签库技术 1. JSTL介绍 在JSP页面中即可书写html,也可以书写Java代码,导致页面混乱,维护,修改,升级难度加大,于是国际上不同的公司在实际应用中,根据页面的需求将Java代 ...
- linux进程管理-定时定期执行任务
0.计划任务的命令: at 安排作业在某一时刻执行 batch 安排作业在系统负载不重时执行 crontab 安排周期性运行的作业 1.at命令用法: 安排命令或者多个命令在指定的时间运行一次 语法 ...
- /proc/diskstats文件注解
/proc/diskstats 注解 今儿在准备利用shell监控磁盘读写次数等信息时,看到该文件,但是又不清楚每段的具体含义,这里备注下. 文件内容 [root@namenode proc]# ca ...
- Coursera助学金申请模板
讲真,我觉得coursera的课还挺贵的.但是它有助学金系统,非常对我们穷学生友好了,而且基本上申请的都会批.不过现在助学金需要15个工作日才有答复,所以注意要提前申请. 有两大段要填. 虽然写的挺烂 ...
- monkey测试===easyMonkey测试【推荐】
easymonkey测试: easymonkey是基于monkey测试的一个二次开发工具.(关于monkey测试参见之前blog) easymonkey的特点就是方便,解决了很多参数命令上设置的麻烦, ...
- 基于 Arduino 开发板,这款插座是可编程且开源的
基于 Arduino 开发板,这款插座是可编程且开源的 https://www.oschina.net/news/74861/open-source-socket https://github.com ...
- PhysX SDK
PhysX SDK https://developer.nvidia.com/physx-sdk NVIDIA PhysX SDK Downloads http://www.nvidia.cn/obj ...
- Mac OSX下Appium驱动iPhone真机
1.安装Xcode.Command Line Tools和Appium. 2.安装brew:/usr/bin/ruby -e "$(curl -fsSL https://raw.github ...
- 在 Visual Studio 中使用正则表达式
Visual Studio 使用 .NET framework 正则表达式查找和替换文本. 在 Visual Studio 2010 和早期版本中,Visual Studio 在“查找和替换”窗口中使 ...