Codeforces Round #200 (Div. 2) E. Read Time(二分)
这题,关键不是二分,而是如果在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(二分)的更多相关文章
- 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 ...
- Codeforces Round #200 (Div. 1)A. Rational Resistance 数学
A. Rational Resistance Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/343 ...
- 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/ ...
- Codeforces Round #200 (Div. 1) B. Alternating Current 栈
B. Alternating Current Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/343 ...
- 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 ...
- Codeforces Round #200 (Div. 1) BCD
为了锻炼个人能力奋力div1 为了不做原题从200开始 B 两个电线缠在一起了 能不能抓住两头一扯就给扯分开 很明显当len为odd的时候无解 当len为偶数的时候 可以任选一段长度为even的相同字 ...
- 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 ...
- Codeforces Round #200 (Div. 1) D. Water Tree(dfs序加线段树)
思路: dfs序其实是很水的东西. 和树链剖分一样, 都是对树链的hash. 该题做法是:每次对子树全部赋值为1,对一个点赋值为0,查询子树最小值. 该题需要注意的是:当我们对一棵子树全都赋值为1的 ...
- Codeforces Round #200 (Div. 1) D Water Tree 树链剖分 or dfs序
Water Tree 给出一棵树,有三种操作: 1 x:把以x为子树的节点全部置为1 2 x:把x以及他的所有祖先全部置为0 3 x:询问节点x的值 分析: 昨晚看完题,马上想到直接树链剖分,在记录时 ...
随机推荐
- win10总是自动重启的解决办法
win10总是自动重启的解决办法_百度经验http://jingyan.baidu.com/article/7908e85c983523af481ad214.html
- 【POJ水题完成表】
题目 完成情况 poj1000:A+B problem 完成 poj1002:电话上按键对应着数字.现在给n个电话,求排序.相同的归一类 完成 poj1003:求最小的n让1+1/2+1/3+...+ ...
- Windows MDL原理总结
http://blog.csdn.net/tbwood/article/details/5400419 http://www.cnblogs.com/jack204/archive/2011/12/2 ...
- Arduino101学习笔记(十四)—— Flash库
一.一些API 1.打开文件 SerialFlashFile file; file = SerialFlash.open("filename.bin"); if (file) { ...
- css3易混淆属性详解
1.background, background-color, color (1)background:在一个声明中设置所有属性: 如:background: #00FF00 url(bgima ...
- hdu1078 dp(递推)+搜索
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1078 题意:老鼠从(1.1)点出发,每次最多只能走K步,而且下一步走的位置的值必须必当前值 ...
- Python与Hack之守护进程
1.什么是守护进程: 在linux或者unix操作系统中,守护进程(Daemon)是一种运行在后台的特殊进程,它独立于控制终端并且周期性的执行某种任务或等待处理某些发生的事件.由于在linux中,每个 ...
- Codeforces Round #375 (Div. 2) - B
题目链接:http://codeforces.com/contest/723/problem/B 题意:给定一个字符串.只包含_,大小写字母,左右括号(保证不会出现括号里面套括号的情况),_分隔开单词 ...
- 学好 Python 的 11 个优秀资源【转载】
Python是目前最流行.最易学最强大的编程语言之一(学习Python的五大理由),无论你是新手还是老鸟,无论是用于机器学习还是web开发(Pinterest就是案例),Python都是一件利器.此外 ...
- JavaOne_2016演讲视频:
http://list.youku.com/albumlist/show?id=28553407&qq-pf-to=pcqq.group