Lice @ 2020-02-09 14:46:43
rt 不知道为什么WA了
orz
#include<cstdio>
#include<functional>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int N=2e6+5;
int n,q;
long long arr[N];
namespace SqrtDiv
{
#define lb(x) ((x-1)*B+1)
#define ub(x) (min(n,x*B))
#define bl(x) ((x-1)/B+1)
const int B=1e3;
const int T=N/B+5;
vector<long long> dat[T];
long long tag[N];
void prework()
{
for(register int i=1;i<=n;i++) dat[bl(i)].push_back(arr[i]);
for(register int i=1;i<=bl(n);i++) sort(dat[i].begin(),dat[i].end());
for(register int i=1;i<=bl(n);i++) tag[i]=0;
}
inline void rebuild(int p)
{
dat[p].clear();
for(register int i=lb(p);i<=ub(p);i++) dat[p].push_back(arr[i]);
sort(dat[p].begin(),dat[p].end());
}
inline void update(int l,int r,long long k)
{
if(bl(l)==bl(r))
{
for(register int i=l;i<=r;i++) arr[i]+=k;
rebuild(bl(l)); return;
}
for(register int i=l;i<=ub(bl(l));i++) arr[i]+=k;
for(register int i=lb(bl(r));i<=r;i++) arr[i]+=k;
rebuild(bl(l)),rebuild(bl(r));
for(register int i=bl(l)+1;i<bl(r);i++) tag[i]+=k;
return;
}
inline int query(int l,int r,long long k)
{
int cnt=0;
if(bl(l)==bl(r))
{
for(register int i=l;i<=r;i++)
if(arr[i]+tag[bl(i)]<k) cnt++;
return cnt;
}
for(register int i=l;i<=ub(bl(l));i++)
if(arr[i]+tag[bl(i)]<k) cnt++;
for(register int i=lb(bl(r));i<=r;i++)
if(arr[i]+tag[bl(i)]<k) cnt++;
for(register int i=bl(l)+1;i<bl(r);i++)
cnt+=lower_bound(dat[i].begin(),dat[i].end(),k-tag[i])-dat[i].begin();
return cnt;
}
}
signed main()
{
// freopen("t.txt","r",stdin);
// freopen("t.out","w",stdout);
scanf("%d%d",&n,&q);
for(register int i=1;i<=n;i++) scanf("%lld",arr+i);
while(q--)
{
char opt; int l,r; long long k;
cin>>opt>>l>>r>>k;
if(opt=='M') SqrtDiv::update(l,r,k);
else cout<<r-l+1-SqrtDiv::query(l,r,k)<<endl;
}
}
by xhQYm @ 2020-02-09 15:58:05
Orz大佬
by 春待ち @ 2020-05-01 10:51:02
改出来了么大佬,萌新也卡60pts了QAQ
by 三废小霸王 @ 2020-07-24 20:17:34
我真是太菜了