
Lv.1
无情刀永不知错 无缘份之叹奈何
签名:卷文化课的同时准备竞赛。
在 【情人节快乐】JROI特别题目讲解 中回复
另外你或许会发现在你窗外闪耀的星星那题很像一些离散化的题目,所以我顺便发一下离散化做法的程序(虽然这题没什么用):
#include<bits/stdc++.h>
using namespace std;
inline int read(){
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
struct node{int x,b;}cl[100005];
int a[100005],n,w,ans,zd,cnt,q[100005],h=1,t,maxn,now;
void discrete(){
for(int i=1;i<=zd;i++)
if(a[i])cl[++cnt].x=i,cl[cnt].b=a[i];
}
int main(){
n=read(),w=read();
for(int i=1;i<=n;i++){
int _1=read(),_2=read();
a[_1]+=_2,zd=max(zd,_1);
}
discrete();
for(int i=1;i<=cnt;i++){
q[++t]=cl[i].x,now+=cl[t].b;
while(q[t]-q[h]>=w)now-=cl[h].b,h++;
maxn=max(maxn,now);
}
printf("%d",maxn);
return 0;
}
这个代码交上去第一个点不知为何RE了,但大体是对的。
2021-02-14T16:43:52 点赞:0
在 【图书馆】如你们所见,现在的图书馆,不是下坡,是自由落体。 中回复
确实,图书馆质量如果像这样持续变差迟早有一天会让编程猫的这一特别之处反而变成影响用户学习的地方
2021-02-14T16:48:27 点赞:1
在 【CSP考前练习 / AKJROI#5】AKJROI#5——国庆假期大赛 中回复
https://shequ.cod喵/community/344342
2021-02-15T14:43:20 点赞:0