A. Office Keys ( Codeforces Round #424 (Div. 1, rated, based on VK Cup Finals) )
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std; int a[];
int b[];
int dp[][];
//dp[i][j] 前i个人从前j个药匙中到达终点的最小时间 int main()
{
int n,k,p;
while(~scanf("%d%d%d",&n,&k,&p))
{
memset(dp,,sizeof(dp));
for(int i=;i<=n;i++) scanf("%d",&a[i]);
for(int i=;i<=k;i++) scanf("%d",&b[i]);
sort(a+,a++n);
sort(b+,b++k); for(int i=;i<=n;i++)
{
for(int j=i;j<=k;j++)
{
if(i==j)
{
dp[i][j]=max(dp[i-][j-],abs(p-b[j])+abs(a[i]-b[j]));
continue;
}
dp[i][j]=min(dp[i][j-],max(dp[i-][j-],abs(p-b[j])+abs(a[i]-b[j])));
}
} int ans = INT_MAX;
for(int i = n;i <= k;i++)
{
ans = min(ans,dp[n][i]);
}
printf("%d\n",ans);
}
return ;
}
A. Office Keys ( Codeforces Round #424 (Div. 1, rated, based on VK Cup Finals) )的更多相关文章
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Office Keys(思维)
Office Keys time limit per test 2 seconds memory limit per test 256 megabytes input standard input o ...
- 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. 1, rated, based on VK Cup Finals) A. Office Keys
选择的钥匙一定是连续的,人和钥匙一定从左到右连续对应. 就枚举钥匙区间即可. #include<cstdio> #include<algorithm> using namesp ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Cards Sorting(树状数组)
Cards Sorting time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- 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 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 E (Codeforces 831E) - 线段树 - 树状数组
Vasily has a deck of cards consisting of n cards. There is an integer on each of the cards, this int ...
随机推荐
- UVA 10529 - Dumb Bones(概率+区间dp)
UVA 10529 - Dumb Bones option=com_onlinejudge&Itemid=8&category=518&page=show_problem&am ...
- eclipse集成SVN插件-----复制添加插件
首先从网上下载一个svn的插件包, 将插件包解压, 打开eclipse的文件夹, 将svn插件中features文件夹中的jar复制到eclipse中features文件夹中去: 将svn插件中plu ...
- windows与mac共享文件
实际操作环境是win10实体机与mac10.10虚拟机共享文件. 需要两步操作: 在win10中设置一个共享文件夹: 在mac中点击Finder——窗口左侧的列表——共享的——共享屏幕——输入用户名密 ...
- appium(8)-locator strategies
locator strategies Finding and interacting with elements Appium supports a subset of the WebDriver l ...
- yum的配置文件yum.conf详解
说明:经过网上抄袭和自己的总结加实验,非常详细,可留作参考. yum的配置一般有两种方式: 一种是直接配置/etc目录下的yum.conf文件, 另外一种是在/etc/yum.repos.d目录下 ...
- 将PHP数组输出为HTML表格
1. [代码][PHP]代码 <?phpclass xtable{ private $tit,$arr,$fons,$sextra; public function __con ...
- 避免复杂的layout
layout是浏览器计算元素的几何信息:元素在页面上的的大小和位置. 每个元素都有明确的亦或含蓄的大小信息,这些信息基于我们使用的css以及元素的内容被高和父亲元素. 这个过程在 Chrome, Op ...
- 【应用】SVG动态 时钟
没有做秒针,只做了分针和时针,5分钟以后来看应该可以看到效果╮(╯-╰)╭ <!DOCTYPE html> <html> <head> <title>& ...
- certificate unknown(46) - 中间证书问题排查
因为腾讯云的网站备案迟迟没有批下来,因此使用了朋友在阿里云的域名yk,我则申请了一台阿里云服务器,并将域名解析映射至该服务器.SSL证书则是在腾讯云上申请的,使用了Apache文件夹中的文件,放置在c ...
- codeforces 701B B. Cells Not Under Attack(水题)
题目链接: B. Cells Not Under Attack 题意: n*n的棋盘,现在放m个棋子,放一个棋子这一行和这一列就不会under attack了,每次放棋子回答有多少点还可能under ...