#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) )的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 【推导】Codeforces Round #424 (Div. 1, rated, based on VK Cup Finals) A. Office Keys

    选择的钥匙一定是连续的,人和钥匙一定从左到右连续对应. 就枚举钥匙区间即可. #include<cstdio> #include<algorithm> using namesp ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. [SCOI2009] 最长距离

    题目描述 windy有一块矩形土地,被分为 NM 块 11 的小格子. 有的格子含有障碍物. 如果从格子A可以走到格子B,那么两个格子的距离就为两个格子中心的欧几里德距离. 如果从格子A不可以走到格子 ...

  2. 云计算系列——HIVE1.2.1 环境搭建

    hive是基于Hadoop的一个数据仓库工具,可以将结构化的数据文件映射为一张数据库表,并提供简单的sql查询功能,可以将sql语句转换为MapReduce任务进行运行. 其优点是学习成本低,可以通过 ...

  3. hihocoder #1094 : Lost in the City微软苏州校招笔试 12月27日 (建图不大【暴力枚举】 子图的4种形态 1Y )

    #1094 : Lost in the City 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi gets lost in the city. He ...

  4. 有待总结的KMP算法 sdut oj 2463 学密码学一定得学程序

    学密码学一定得学程序 Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 曾经,ZYJ同学非常喜欢密码 学.有一天,他发现了一个很长很 ...

  5. Bestcoder round 18---A题(素数筛+素数打表+找三个素数其和==n)

    Primes Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  6. RBAC打造通用web管理权限

    https://www.cnblogs.com/lamp01/p/6576432.html https://www.imooc.com/learn/799

  7. 发布镶嵌数据集,服务端Raster Function制作

    1.新建GDB 2.GDB里右键,New 镶嵌数据集. 3.向镶嵌数据集中添加风速TIF. 4.利用原样式,导出一个函数模板. 导出是XML. 5.发布ImageService服务时,在Functio ...

  8. python学习笔记:第四天( 字符串)

    Python3 字符串 字符串是 Python 中最常用的数据类型.我们可以使用引号('或")来创建字符串. 在Python2中,普通字符串是以8位ASCII码进行存储的,而Unicode字 ...

  9. CF 1009 F Dominant Indices —— 长链剖分+指针

    题目:http://codeforces.com/contest/1009/problem/F 也可以用 dsu on tree 的做法,全局记录一个 dep,然后放进堆里,因为字典序要最小,所以再记 ...

  10. POJ1226(strstr)

    Substrings Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 13348   Accepted: 4722 Descr ...