Tom owns a company and he is the boss. There are n staffs which are numbered from 1 to n in this company, and every staff has a ability. Now, Tom is going to assign a special task to some staffs who were in the same group. In a group, the difference…
思路: 对于每一个r 要找最小的符合条件的l最优 这时候就要找在这个区间中 d长度的和的最大值 用单调队列更新就好了 //By SiriusRen #include <cstdio> #include <algorithm> using namespace std; #define N 2000100 long long sum[N],p,g[N]; int n,d,w[N],head,tail,l,ans,que[N]; signed main(){ scanf("%d…
[题意] 维护一个单调递减的q数组,用id数组记录q数组的每个下标对应在原数组的位置,那么id数组一定有单调性(q数组中越靠后,原数组中也靠后),然后二分查找这个数 [AC] #include<bits/stdc++.h> using namespace std; typedef long long ll; int n,d; ; int q[maxn],id[maxn]; int tail;int cnt; int last; void add(int x) { while(tail&…