A Shade of Moonlight

列列式子发现, 对于同一个云来说只有反向的云才能和它相交, 然后我们发现这个东西有单调性,然后二分就好啦。

#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mk make_pair
#define PLL pair<LL, LL>
#define PLI pair<LL, int>
#define PII pair<int, int>
#define SZ(x) ((int)x.size())
#define ull unsigned long long using namespace std; const int N = 1e5 + ;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + ;
const double eps = 1e-;
const double PI = acos(-); int n, l, w;
vector<int> a;
vector<int> b; bool check(int x1, int x2) {
return abs(x1 + x2 + l) < 1LL * (x2 + l - x1) * w;
} int main() {
scanf("%d%d%d", &n, &l, &w);
for(int i = ; i <= n; i++) {
int x, v; scanf("%d%d", &x, &v);
if(v == ) a.push_back(x);
else b.push_back(x);
}
LL ans = ;
sort(a.begin(), a.end());
sort(b.begin(), b.end());
for(auto& x2 : b) {
int low = ;
int high = lower_bound(a.begin(), a.end(), x2) - a.begin() - ;
int p = -;
while(low <= high) {
int mid = (low + high) >> ;
if(check(a[mid], x2)) p = mid, low = mid + ;
else high = mid - ;
}
ans += p + ;
}
printf("%lld\n", ans);
return ;
} /*
*/

Codeforces 989D A Shade of Moonlight的更多相关文章

  1. A Shade of Moonlight CodeForces - 989D

    看这位博主的吧:https://blog.csdn.net/Steaunk/article/details/80660954

  2. *Codeforces989D. A Shade of Moonlight

    数轴上$n \leq 100000$个不重叠的云,给坐标,长度都是$l$,有些云速度1,有些云速度-1,风速记为$w$,问在风速不大于$w_{max}$时,有几对云可能在0相遇.每一对云单独考虑. 多 ...

  3. CF #487 (Div. 2) D. A Shade of Moonlight 构造_数形结合

    题意: 给 nnn个长度为 lll 且互不相交的开区间 (xi,xi+l)(x_{i}, x_{i}+l)(xi​,xi​+l) ,每个区间有一个移动速度 vvv,v∈1,−1v∈1,-1v∈1,−1 ...

  4. CodeForces 989D

    题意略. 思路: 可以看成是所有的云彩照常运动,而月亮在跑.只要两个云彩相交后,在分离前月亮能赶到,就算是符合题意的. 可以知道,两个相隔越远的相向运动地云彩是越有可能符合题意的,因为它们相遇所用时间 ...

  5. codeforces 148D之概率DP

    http://codeforces.com/problemset/problem/148/D D. Bag of mice time limit per test 2 seconds memory l ...

  6. Codeforces Round #105 (Div. 2) D. Bag of mice 概率dp

    题目链接: http://codeforces.com/problemset/problem/148/D D. Bag of mice time limit per test2 secondsmemo ...

  7. Codeforces 148 D Bag of mice

    D. Bag of mice http://codeforces.com/problemset/problem/148/D time limit per test 2 seconds memory l ...

  8. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  9. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

随机推荐

  1. 利用表格分页显示数据的js组件datatable的使用

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. 缓存系列之五:通过codis3.2实现redis3.2.8集群的管理

    通过codis3.2实现redis3.2.8集群 一:Codis 是一个分布式 Redis 解决方案, 对于上层的应用来说, 连接到 Codis Proxy 和连接原生的 Redis Server 没 ...

  3. OpenSIPS 1.11.1安装记录

    说明:操作系统Centos 6.5  64位 安装步骤: 1.安装依赖包 : yum -y install gcc make gdb wget yum -y install flex bison nc ...

  4. Linux命令之useradd和userdel(添加、删除用户)

    一.[useradd]:添加用户命令 1.作用 useradd或adduser命令用来建立用户帐号和创建用户的起始目录,使用权限是超级用户. 2.格式 useradd [-d home] [-s sh ...

  5. 【原创】大叔经验分享(32)docker挂载文件修改生效

    docker经常需要挂载文件到容器中,比如启动nginx # docker run -d --name test_nginx -v /tmp/nginx.conf:/etc/nginx/nginx.c ...

  6. Spring加载加密的配置文件

    一.继承并实现自己的属性文件配置器类 /** * 带加密的Spring属性配置文件扩展类 * 加密方式:AES * @author simon * */ public class EncryptPro ...

  7. 用Python优雅的处理日志

    我们可以通过以下3种方式可以很优雅配置logging日志: 1)使用Python代码显式的创建loggers, handlers和formatters并分别调用它们的配置函数: 2)创建一个日志配置文 ...

  8. 牛客网 python 求解立方根

    •计算一个数字的立方根,不使用库函数 详细描述: •接口说明 原型: public static double getCubeRoot(double input) 输入:double 待求解参数 返回 ...

  9. mybatis 按in 函数参数顺序排序

    使用 FIELD()函数 SELECT *  FROM   user  WHERE id IN (72, 80, 69)  ORDER BY FIELD(id, 72, 80, 69)

  10. Oauth2.0 QQ&微信&微博实现第三方登陆

    一.写在前面 目前对于大多数的App或Web网站都支持有第三方登陆这个功能,用户可使用 QQ/ 微信/ 微博 帐号快速登录你的网站,降低注册门槛,为你的网站带来海量新用户.最近在新项目上刚好用到了,在 ...