思路:

  背包;

代码:

#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define maxn 1005
#define maxk 2005
#define ll long long
int n,k,p;
ll dp[maxn][maxk],ai[maxn],bi[maxk];
inline void in(int &now)
{
char Cget=getchar();now=;
while(Cget>''||Cget<'') Cget=getchar();
while(Cget>=''&&Cget<='')
{
now=now*+Cget-'';
Cget=getchar();
}
}
inline void in(ll &now)
{
char Cget=getchar();now=;
while(Cget>''||Cget<'') Cget=getchar();
while(Cget>=''&&Cget<='')
{
now=now*+Cget-'';
Cget=getchar();
}
}
inline ll check()
{
//memset(dp,127/3,sizeof(dp));
for(int i=;i<=n;i++)
for(int v=;v<=k;v++)
dp[i][v]=max(dp[i-][v-],abs(ai[i]-bi[v])+abs(bi[v]-p));
ll Min=2e9;
for(int i=n;i<=k;i++) Min=min(dp[n][i],Min);
return Min;
}
int main()
{
in(n),in(k),in(p);
for(int i=;i<=n;i++) in(ai[i]);
for(int i=;i<=k;i++) in(bi[i]);
sort(ai+,ai+n+),sort(bi+,bi+k+);
cout<<check();
return ;
}

AC日记——830A - Office Keys的更多相关文章

  1. Codeforces 830A. Office Keys (贪心二分 or DP)

    原题链接:http://codeforces.com/contest/830/problem/A 题意:在一条数轴上分别有n个人和k把钥匙(n<=k),以及一个目的地,每个人要各自拿到一个钥匙后 ...

  2. AC日记——codevs1688求逆序对

    AC日记--codevs1688求逆序对 锵炬 掭约芴巷 枷锤霍蚣 蟠道初盛 到被他尽情地踩在脚下蹂躏心中就无比的兴奋他是怎么都 ㄥ|囿楣 定要将他剁成肉泥.挫骨扬灰跟随着戴爷这么多年刁梅生 圃鳋 ...

  3. CF830A Office Keys(贪心)

    CF830A Office Keys [题目链接]CF830A Office Keys [题目类型]贪心 &题意: 有n个人,k个钥匙,一个目的地,求让n个人都回到目的地的最短时间,每个人都要 ...

  4. Codeforces831D Office Keys

    D. Office Keys time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

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

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

  7. codeforce830A. Office Keys

    A. Office Keys time limit per test: 2 seconds memory limit per test: 256 megabytes input standard: i ...

  8. AC日记——Valued Keys codeforces 801B

    801B - Valued Keys 思路: 水题... 来,上代码: #include <cstdio> #include <cstring> #include <io ...

  9. code force 424 A - Office Keys

    There are n people and k keys on a straight line. Every person wants to get to the office which is l ...

随机推荐

  1. Oracle中用exp/imp命令参数详解【转】

    Oracle中用exp/imp命令参数详解 [用 exp 数 据 导 出]:1  将数据库TEST完全导出,用户名system 密码manager 导出到D:\daochu.dmp中   exp sy ...

  2. 2018-2019 ACM-ICPC 焦作赛区 部分题解

    题目链接:https://codeforces.com/gym/102028 B. Ultraman vs. Aodzilla and Bodzilla 题意: 两只怪兽,它们的生命和攻击分别为hpA ...

  3. Scrapy的安装--------Windows、linux、mac等操作平台

    Scrapy安装 Scrapy的安装有多种方式,它支持Python2.7版本及以上或者是Python3.3版本及以上.下面来说py3环境下,scrapy的安装过程. Scrapy依赖的库比较多,至少需 ...

  4. 不修改代码优化 ASP.NET 网站性能的一些方法

    本文将介绍一些方法用于优化ASP.NET网站性能,这些方法都是不需要修改程序代码的.它们主要分为二个方面:1. 利用ASP.NET自身的扩展性进行优化.2. 优化IIS设置. 配置OutputCach ...

  5. [转]FILE的用法

    #include <stdio.h> int main() { char c; ; FILE *file; file = fopen("test.txt", " ...

  6. 【BZOJ】1087: [SCOI2005]互不侵犯King

    [算法]状态压缩型DP [题解]http://www.cnblogs.com/xtx1999/p/4620227.html (orz) https://www.cnblogs.com/zbtrs/p/ ...

  7. oozie与sqoop的简单案例

    1:拷贝模板 2:拷贝hive用的jar包 方式一: 3:编辑job.properties # # Licensed to the Apache Software Foundation (ASF) u ...

  8. echarts初探:了解模块化

    什么是echarts?这是官网:http://echarts.baidu.com/ 简单的说就是百度提供的一些画图表的库,用它你可以简便的画出一些你想要的图表效果. 虽然蛮好用的,但对于不知道模块化的 ...

  9. 【leetcode 简单】第十一题 搜索插入位置

    给定一个排序数组和一个目标值,在数组中找到目标值,并返回其索引.如果目标值不存在于数组中,返回它将会被按顺序插入的位置. 你可以假设数组中无重复元素. 示例 1: 输入: [1,3,5,6], 5 输 ...

  10. 生成验证码tp

    js里拼接随机数 页面上链接 去掉后缀名