Codeforces 989D 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的更多相关文章
- A Shade of Moonlight CodeForces - 989D
看这位博主的吧:https://blog.csdn.net/Steaunk/article/details/80660954
- *Codeforces989D. A Shade of Moonlight
数轴上$n \leq 100000$个不重叠的云,给坐标,长度都是$l$,有些云速度1,有些云速度-1,风速记为$w$,问在风速不大于$w_{max}$时,有几对云可能在0相遇.每一对云单独考虑. 多 ...
- 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 ...
- CodeForces 989D
题意略. 思路: 可以看成是所有的云彩照常运动,而月亮在跑.只要两个云彩相交后,在分离前月亮能赶到,就算是符合题意的. 可以知道,两个相隔越远的相向运动地云彩是越有可能符合题意的,因为它们相遇所用时间 ...
- codeforces 148D之概率DP
http://codeforces.com/problemset/problem/148/D D. Bag of mice time limit per test 2 seconds memory l ...
- 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 ...
- 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 ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
随机推荐
- MySQL联结查询和子查询
2018-2-24 16:18:12 星期六 今天需要统计一个运营活动的数据, 涉及三个表, 分组比较多 活动描述: 每个人可以领取多张卡片, 好友也可以赠送其卡片, 20或40张卡片可以兑换一个奖 ...
- 【原创】运维基础之OpenResty(Nginx+Lua)+Kafka
使用docker部署 1 下载 # wget https://github.com/doujiang24/lua-resty-kafka/archive/v0.06.tar.gz# tar xvf v ...
- auth模块(登录验证)
settings:'django.contrib.auth.middleware.AuthenticationMiddleware',#这个是认证的中间件,认证成功的话,就可以把这个用户user封装到 ...
- js混淆、eval解密
js中的eval()方法就是一个js语言的执行器,它能把其中的参数按照JavaScript语法进行解析并执行,简单来说就是把原本的js代码变成了eval的参数,变成参数后代码就成了字符串,其中的一些字 ...
- Android 各种路径详细说明
存储分类: 内部存储路径, 内部缓存存储路径, 外部存储路径, 外部缓存存储路径 在有些手机上内部划出一个内部的sdcard路径和内部存储路径,当有sdcard时候,就有了六个路径 内部存储空间中的应 ...
- 时间格式化 Date-formatDate
//日期格式化 export function formatDate(date,fmt){ var o = { "M+":date.getMonth() + 1,//月份 &quo ...
- 一种基于NTC的控温电路及软件实现
NTC(Negative Temperature Coefficient)是一种随温度上升时,电阻值呈指数关系减小的热敏电阻.应用广泛,最近我们就采用了NTC来控制加热并测温,并达到了预期的效果. 1 ...
- UserNotifications ios10 通知使用
通知在ios10 中推荐使用 导入 import UserNotifications 头文件 if #available(iOS 10.0, *) { UNUserNotificationCent ...
- nginx(一)之默认配置文件
首先是nginx.conf vim /etc/nginx/nginx.conf user nginx; // 设置nginx服务的系统使用用户 worker_processes 1; // 工作进程数 ...
- 【python】ftp连接,主被动,调试等级
示例代码如下: #!/usr/bin/env python # -*- coding: utf-8 -*- import os from ftplib import FTP def ftp_down( ...