#include #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; class union_find{ int n; vector p; public: union_find(int n):n(n),p(n,-1){} int find(int u){ return p[u]<0?u:p[u]=find(p[u]); } void unite(int u,int v){ u=find(u); v=find(v); if(u!=v){ if(p[v] x(n); rep(i,n) scanf("%d",&x[i]); union_find U(n); vector sum(n+1); rep(i,n){ int l=lower_bound(x.begin(),x.end(),x[i]+a)-x.begin(); int r=upper_bound(x.begin(),x.end(),x[i]+b)-x.begin(); if(l0) U.unite(i,i+1); rep(i,n) printf("%d\n",U.size(i)); return 0; }