Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Greedy Subseqs 11/21
- LazySegTree<int,MX> L;
- int n,k,lef[MX];
- vi a;
- vpi v;
- int main() {
- // you should actually read the stuff at the bottom
- setIO(); re(n,k); a.resz(n); re(a);
- F0R(i,n) {
- int l = i;
- while (sz(v) && a[v.back().s] < a[i]) {
- l = v.back().f;
- v.pop_back();
- }
- lef[i] = l;
- v.pb({l,i});
- }
- F0R(i,n) {
- L.upd(lef[i],i,-1);
- if (i >= k-1) pr(-L.qmin(i-(k-1),i)," ");
- }
- // you should actually read the stuff at the bottom
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement