CF 84D Doctor(二分)】的更多相关文章

题目链接: 传送门 Doctor time limit per test:1 second     memory limit per test:256 megabytes Description There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and…
1.CF 706B  Interesting drink 2.链接:http://codeforces.com/problemset/problem/706/B 3.总结:二分 题意:给出n个数,再给出q个mi,每次求n个数里有多少个数<=mi #include<iostream> #include<cstring> #include<cmath> #include<queue> #include<algorithm> #include&l…
链接:http://codeforces.com/contest/1244/problem/E 题意: 给定包含$n$个数的数组,你可以执行最多k次操作,使得数组的一个数加1或者减1. 问合理的操作,使得数组中最大的数和最小的数差值最小. 思路: 二分答案,重点是检查的时候需要跑两遍. // #pragma GCC optimize(2) // #pragma GCC optimize(3) // #pragma GCC optimize(4) #include <algorithm> #in…
题目:http://codeforces.com/problemset/problem/1042/A #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; ; int n,m,a[N],ans,mx; int main() { scanf("%d%d",&n,&m); ;i<=n;i…
分析:一辆车最多载k个人,车的速度肯定比人快,所以想要到达时间最短,那么每个人必须做一次公交车.那么把n个人分成p=(n+k-1)/k组.设最短时间为t,每人乘车时间为t1,则t1*v2+(t-t1)*v1=L.设每次车子返回走的时间为t2,则(t1+t2)*v1+t2*v2=t1*v2.由这两个式子可以写出t1,t2的表达式.又因为p*t1+(p-1)*t2=t. 所以可以以最短时间L/v2为左端值,以L/v1为右端值二分t. #include <iostream> #include <…
D. Monitor time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Recently Luba bought a monitor. Monitor is a rectangular matrix of size n × m. But then she started to notice that some pixels ce…
This article is made by Jason-Cow.Welcome to reprint.But please post the writer's address. http://www.cnblogs.com/JasonCow/ [NOIP2015]运输计划    Hello!链剖.你好吗? 题意: 给出一棵n个节点的带权树,m对树上点对 现在允许删除一条边,(权值修改为0) 输出: 最小化的点对间最大距离 1.链剖 2.树上差分 3.二分 链剖我就不多说了,就是两dfs 注意…
CF 600B 题目大意:给定n,m,数组a(n个数),数组b(m个数),对每一个数组b中的元素,求数组a中小于等于数组该元素的个数. 解题思路:对数组a进行排序,然后对每一个元素b[i],在数组a中进行二分查找第一个大于b[i]的位置即为结果 /* CF 600B Queries about less or equal elements --- 二分查找 */ #include <cstdio> #include <algorithm> using namespace std;…
为什么Cf上所有的交互题都是$binary \; Search$... 把序列分成前后两个相等的部分,每一个都可以看成一条斜率为正负$1$的折线.我们把他们放在一起,显然,当折线的交点的横坐标为整数时有解. 我们考虑序列元素$a_{i}, a_{i + \frac{n}{2}}$,他们的差的奇偶性对于每一个$i$都是一样的,因为随着横坐标的增加,纵坐标之差要么不变,要么加减$2$. 显然如果我们询问$a_{1}, a_{1 + \frac{n}{2}}$的差是奇数,那就不可能存在解了. 我们把折…
CF 1405E Fixed Point Removal[线段树上二分]  题意: 给定长度为\(n\)的序列\(A\),每次操作可以把\(A_i = i\)(即值等于其下标)的数删掉,然后剩下的数组拼接起来,问最多能删多少个数 \(q\)次独立询问,每次把前\(x\)个数和\(后\)后\(y\)个数置为\(n+1\)之后解决上述问题 题解: 先不考虑把前\(x\)个数和后\(y\)个数置成\(n+1\)的情况 首先我们可以想到的是把所有数的值减去其下标,定义\(B_i = A_i - i\),…