CF1710B Rain
首先,只需要考虑降雨中心即可。
证明:所有函数在两个相邻中心之间是下凸的,所以和也是下凸的,所以中间小于两端。
用二维差分容易求出各点的降雨量。
对于一个高度大于
#include <cstdio>
#include <algorithm>
#include <cctype>
#include <map>
using namespace std;
char buf[1<<14], *p1=buf, *p2=buf;
#define GetC() ((p1==p2)&&(p2=(p1=buf)+fread(buf,1,1<<14,stdin),p1==p2)?EOF:*p1++)
struct Ios{}io;
template <typename _tp>
Ios &operator >>(Ios &in, _tp &x){
x=0; int w=0; char c=GetC();
for(;!isdigit(c);w|=c=='-', c=GetC());
for(;isdigit(c);x=x*10+(c^'0'), c=GetC());
if(w) x=-x;
return in;
}
using ll=long long;
const int N=2e5+5;
const ll inf=1e18;
ll x[N], p[N];
map<ll, ll> d;
int main(){
int T; io>>T;
while(T--){
d.clear();
int n, m; io>>n>>m;
for(int i=1;i<=n;++i){
io>>x[i]>>p[i];
++d[x[i]-p[i]+1]; d[x[i]+1]-=2; ++d[x[i]+p[i]+1];
}
ll b=0, k=0, lst=-inf;
ll b1=-inf, b2=-inf;
for(auto cur:d){
b+=k*(cur.first-lst);
k+=cur.second;
if(b>m){
b1=max(b1, b-m-cur.first+1);
b2=max(b2, b-m+cur.first-1);
}
lst=cur.first;
}
for(int i=1;i<=n;++i)
printf("%d", (p[i]>=x[i]+b1)&&(p[i]>=b2-x[i]));
puts("");
}
return 0;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 一文读懂知识蒸馏
· 终于写完轮子一部分:tcp代理 了,记录一下