题目链接

这题,关键不是二分,而是如果在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. 【翻译三】java-并发之线程对象和实现

    Thread Objects Each thread is associated with an instance of the class Thread. There are two basic s ...

  2. 【JAVA单例模式详解】

    设计模式是一种思想,适合于任何一门面向对象的语言.共有23种设计模式. 单例设计模式所解决的问题就是:保证类的对象在内存中唯一. 举例: A.B类都想要操作配置文件信息Config.java,所以在方 ...

  3. 【PHP&&mysqli】

    msyqli和mysql只有一个字母的差别,真正的含义是msyql的增强版扩展. MySQL可以处理满足程序员对MySQL数据库操作的各种需要了,为什么还需要mysqli呢?因为mysqli支持面性对 ...

  4. SSH入门简单搭建例子

    因为公司涉及项目使用SSH,为了解SSH搭建方式和运作原理,就自己搭建了一个. 采用尽量以最少的JAR包,搭建一个简单的struts2+spring+hibernate环境,希望像我这样的入门者都能理 ...

  5. Linux环境下使用shell编写CGI(httpd)

    /var/www/cgi-bin/hello.sh #!/bin/bash echo "Content-type: text/html" echo "" ech ...

  6. COALESCE NVL NVL2 DECODE

    1 COALESCE 語法:COALESCE(expr1, expr2, ..., exprn) n>=2 作用:COALESCE returns the first non-null expr ...

  7. [Linux][VMWare] 学习笔记之安装Linux系统-网络配置

    最近开始折腾Linux,在本机装了个VMWare和Centos,装完之后虚拟机里面的OS可以上网,但是使用SecureCRT连接不上虚拟机,开始折腾这个网络. vmware安装好以后,会自动添加两张网 ...

  8. Waiting Processed Cancelable ShowDialog

    namespace ConsoleApplication { using System; using System.Threading; using Microshaoft; /// <summ ...

  9. POJ 1984 Navigation Nightmare 带全并查集

    Navigation Nightmare   Description Farmer John's pastoral neighborhood has N farms (2 <= N <= ...

  10. HeapSort自己yy-未完成

    #include <iostream> #include <cstdio> using namespace std; ; int a[maxn]; int HeapSize; ...