【推导】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 ...
随机推荐
- TOJ 1049 Jesse's problem (最短路 floyd)
描述 All one knows Jesse live in the city , but he must come to Xiasha twice in a week. The road is to ...
- [IOS]Xcode各版本官方下载及百度云盘下载, Mac和IOS及Xcode版本历史
官方下载, 用开发者账户登录,建议用Safari浏览器下载. 官方下载地址: https://developer.apple.com/xcode/downloads/ 百度云盘下载地址 http:// ...
- SQL SERVER 创建远程数据库链接 mysql oracle sqlserver
遇到的坑 在连接Oracle时,因为服务器为10g 32位版本,然后在本地安装了32为10g客户端,然后一直报错[7302.7303],后来下载了12c 64位版本,安装成功后,问题解决 原因:mss ...
- H5特性 MutationObserver 监听元素 动态改变iframe高度
这些代码要写在iframe页中执行 <script type="text/javascript"> $(function () { // Firefox和Chrome早 ...
- 计算机网络课设之基于UDP协议的简易聊天机器人
前言:2017年6月份计算机网络的课设任务,在同学的帮助和自学下基本搞懂了,基于UDP协议的基本聊天的实现方法.实现起来很简单,原理也很简单,主要是由于老师必须要求使用C语言来写,所以特别麻烦,而且C ...
- H264协议(转)
码率(Bitrate).帧率(FPS).分辨率和清晰度的联系与区别:https://blog.csdn.net/pc9319/article/details/79621352 H.264编码原理以及I ...
- Bookmarks www
Bookmarks alexis- (Alex Incogito) - Repositories · GitHub GitHub - aetcnc-Arduino_DeltaHMI_RS485 Ope ...
- 【bzoj4486】【JSOI2015】串分割
老省选题了. 首先考虑怎么比较超长数字的大小? 参见UTR1的那道题 先比size,然后比较字典序即可. 接下来考虑下切割的问题. 因为要将字符串切割成k份,所以这个字符串只会存在n/k个本质不同的起 ...
- iOS一个项目开始创建, 部署到git服务器
在做iOS开发时, 最开始可能你的经理部署项目, 所以你不会插手, 只是直接从git上clone下来然后就开始撸码, 如果有一天你做经理了, 你怎么去部署一个项目呢, 下面我来过一遍流程 1. 首先需 ...
- ASP .NET CORE 部署linux 系统上的所需要的sdk 使用链接
https://www.microsoft.com/net/learn/get-started/linuxopensuse