[Codeforces 875E] Delivery Club
来源:互联网 发布:java做手机游戏 编辑:程序博客网 时间:2024/06/05 02:08
题目链接: http://codeforces.com/problemset/problem/875/E
题目大意:有两个快递员A, B, 他们的初始坐标为
思路: 考虑二分答案来判断合法性。 若二分了答案为x, 倒过来考虑这n个点。 我们考虑计算当其中一个快递员在
#include <cstdio>#include <cstdlib>#include <algorithm>using namespace std;const int N = (int)1e5 + 10;int n, s1, s2, a[N]; bool check(int x){ int l = a[n] - x, r = a[n] + x; for (int i = n - 1; i >= 1; i --){ if (l <= a[i] && a[i] <= r) l = a[i] - x, r = a[i] + x; else{ l = max(a[i] - x, l); r = min(a[i] + x, r); if (l > r) return 0; } } return (l <= s1 && s1 <= r) || (l <= s2 && s2 <= r);}int main(){ scanf("%d%d%d", &n, &s1, &s2); if (s1 < s2) swap(s1, s2); for (int i = 1; i <= n; i ++) scanf("%d", a + i); int l = s1 - s2, r = (int)1e9, ans; while (l <= r){ int mid = (l + r) >> 1; if (check(mid)) ans = mid, r = mid - 1; else l = mid + 1; } printf("%d\n", ans); return 0;}
阅读全文
0 0
- Codeforces 875E-Delivery Club
- [Codeforces 875E] Delivery Club
- Codeforces 875E Delivery Club 妙哉!
- [杂题 SET维护DP] Codeforces 875E. Delivery Club
- [SET维护DP] Codeforces #875E. Delivery Club
- Codeforces Round #441 (Div. 1, by Moscow Team Olympiad) E. Delivery Club
- Mishap in Club--codeForces 245E--贪心
- CodeForces 245E Mishap in Club
- 【Codeforces875E】Delivery Club
- Codeforces 635E Package Delivery【贪心】
- [ ST表 ] Codeforces875E Delivery Club
- E. Mishap in Club (CF 245E)
- codeforces 198 Malek Dance Club
- CodeForces 653D Delivery Bears
- Codeforces 320C Malek Dance Club【规律】
- Delivery
- Codeforces Gym 100783D Book Club(匈牙利算法)
- codeforces 163E e-Government
- 了解这些电源知识能提高机房供电可靠性
- 9,数据挖掘环境搭建-IDEA MAVEN搭建Spark开发环境,2个问题
- eclipse Java web项目 修改文件不生效 project clean后项目无法访问
- 阿里云官方认证加盟双十一!热门技能认证低至0.1元,ACA认证6.6折
- 大学英语单词T
- [Codeforces 875E] Delivery Club
- 文章标题
- Struts2(七)---异常处理
- php系统搬迁以后mysql无法链接
- WDF驱动模型
- 子fragment无限轮播
- 基于X210开发板平台下的刷机教程
- 消费者洞察:一文看懂消费者是如何做选择的
- 线下沙龙 | 优秀的产品经理,你懂得如何“增长”吗?内含送票福利!