题目链接

这题,关键不是二分,而是如果在t的时间内,将n个头,刷完这m个磁盘。

看了一下题解,完全不知怎么弄。用一个指针从pre,枚举m,讨论一下。只需考虑,每一个磁盘是从右边的头,刷过来的(左边来的之前刷了)。

思维是硬伤。

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define LL __int64
LL p[],h[];
int n,m;
int judge(LL x)
{
int pre = ;
LL temp;
int i;
for(i = ;i < n;i ++)
{
if(abs(p[pre]-h[i]) > x) continue;
if(p[pre] < h[i])
temp = h[i] + max((x-(h[i]-p[pre]))/,x-*(h[i]-p[pre]));
else
temp = h[i] + x;
while(p[pre] <= temp&&pre < m)pre ++;
}
if(pre == m)
return ;
else
return ;
}
LL bin()
{
LL str,end,mid;
str = ;
end = 100000000000000ll;
while(str < end)
{
mid = (str + end)/;
if(judge(mid))
end = mid;
else
str = mid + ;
}
return str;
}
int main()
{
int i;
scanf("%d%d",&n,&m);
for(i = ;i < n;i ++)
{
scanf("%I64d",&h[i]);
}
for(i = ;i < m;i ++)
{
scanf("%I64d",&p[i]);
}
printf("%I64d\n",bin());
return ;
}

Codeforces Round #200 (Div. 2) E. Read Time(二分)的更多相关文章

  1. Codeforces Round #200 (Div. 1) C. Read Time 二分

    C. Read Time Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/343/problem/C ...

  2. Codeforces Round #200 (Div. 1)A. Rational Resistance 数学

    A. Rational Resistance Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/343 ...

  3. Codeforces Round #200 (Div. 1)D. Water Tree dfs序

    D. Water Tree Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/343/problem/ ...

  4. Codeforces Round #200 (Div. 1) B. Alternating Current 栈

    B. Alternating Current Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/343 ...

  5. Codeforces Round #200 (Div. 2) C. Rational Resistance

    C. Rational Resistance time limit per test 1 second memory limit per test 256 megabytes input standa ...

  6. Codeforces Round #200 (Div. 1) BCD

    为了锻炼个人能力奋力div1 为了不做原题从200开始 B 两个电线缠在一起了 能不能抓住两头一扯就给扯分开 很明显当len为odd的时候无解 当len为偶数的时候 可以任选一段长度为even的相同字 ...

  7. Codeforces Round #200 (Div. 2)D. Alternating Current (堆栈)

    D. Alternating Current time limit per test 1 second memory limit per test 256 megabytes input standa ...

  8. Codeforces Round #200 (Div. 1) D. Water Tree(dfs序加线段树)

    思路: dfs序其实是很水的东西.  和树链剖分一样, 都是对树链的hash. 该题做法是:每次对子树全部赋值为1,对一个点赋值为0,查询子树最小值. 该题需要注意的是:当我们对一棵子树全都赋值为1的 ...

  9. Codeforces Round #200 (Div. 1) D Water Tree 树链剖分 or dfs序

    Water Tree 给出一棵树,有三种操作: 1 x:把以x为子树的节点全部置为1 2 x:把x以及他的所有祖先全部置为0 3 x:询问节点x的值 分析: 昨晚看完题,马上想到直接树链剖分,在记录时 ...

随机推荐

  1. Delphi中uses在interfeace和implementation中的区别

    use单元引入分为在interface中引入,如 interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Co ...

  2. java-解决业务操可能数据冲突问题

    问题提出,由于业务会出现多人同时操作,或者业务人员反复的操作,因此在业务流程中,需要对业务操作数据进行保护,由于使用数据库锁可能会引起一些难以预料的问题,因此考虑使用内存锁,设计思想:在内存中使用一个 ...

  3. Oracle的thin驱动和oci驱动有什么不同?哪个性能好些?

    OCI:要安装ORACLE客户端,移植性略差,理论上性能好些 THIN:属于TYPE4,纯JAVA实现,移植性好,理论上性能略差些 推荐:最好还是使用THIN   DRIVER吧,移植性好些,使用起来 ...

  4. [读书笔记] Web 前端开发修炼之道

    原创地址:http://www.cnblogs.com/bnbqian/p/3735565.html 转载请注明出处 今天我们要读的书是Web 前端开发修炼之道 第1章 从网站重构说起 1.1 糟糕的 ...

  5. Oracle性能优化之SQL语句

    1.SQL语句执行过程 1.1 SQL语句的执行步骤 1)语法分析,分析语句的语法是否符合规范,衡量语句中各表达式的意义. 2)语义分析,检查语句中涉及的所有数据库对象是否存在,且用户有相应的权限. ...

  6. bbed的使用--安装及初探

    bbed是oracle内部一款用来直接查看和修改数据文件数据的工具,可以直接修改Oracle数据文件块的内容,在一些特殊恢复场景下比较有用. 1.bbed 的安装 在9i/10g中连接生成bbed: ...

  7. codeforces 45C C. Dancing Lessons STL

    C. Dancing Lessons   There are n people taking dancing lessons. Every person is characterized by his ...

  8. 2016 ACM/ICPC Asia Regional Dalian Online HDU 5877 Weak Pair treap + dfs序

    Weak Pair Problem Description   You are given a rooted tree of N nodes, labeled from 1 to N. To the  ...

  9. zTree学习文档和DEOM

    http://tool.oschina.net/apidocs/apidoc?api=ztree3.2%2Fapi%2FAPI_cn.html zTree的API http://www.ztree.m ...

  10. Arduino101学习笔记(四)—— 数字IO

    1.设置管脚模式 //***************************************************************************************** ...