求解

P3353 在你窗外闪耀的星星

标签 贪心 线段树
by SmallBlack @ 2020-04-15 07:46:01


@[do_while_true](/user/223298) ???我还真不知道线段树是这样写的
by FZzzz @ 2020-04-15 07:54:42


@[do_while_true](/user/223298) 这不是单点修改吗23333
by Mr_Greeper @ 2020-04-15 07:55:49


@[Mr_Greeper](/user/189342) @[FZzzz](/user/174045) 啊我菜鸡了,我还以为是区间修改
by do_while_true @ 2020-04-15 09:13:52


直接暴力+O2 ```cpp #include<stdio.h>//TLE吧 using namespace std; int n,m,sum,maxn=-1e9,ll,lo;int s[100005]; int main(){ scanf("%d%d",&n,&m); for(int i=0;i<n;i++){ scanf("%d%d",&ll,&lo); s[ll]+=lo; } for(int i=1;i<=100005;i++){ sum=0; for(int j=i;j<i+m;j++){ if(i+m>100000) break; sum+=s[j]; } if(sum>maxn) maxn=sum; } printf("%d",maxn); return 0; } ```
by _buzhidao_ @ 2023-05-04 13:22:10


|