显示代码纯文本
#include<cstdio>
#include<cctype>
const int maxn=100010;
int c1[maxn],c2[maxn];//c1:攻击次数 c2:伤害吨数
int h[maxn],d[maxn];int n;
inline int getsum1(int x){
int ans=0;
for(int i=x;i;i-=(i&-i))ans+=c1[i];
return ans;
}
inline int getsum2(int x){
int ans=0;
for(int i=x;i;i-=(i&-i))ans+=c2[i];
return ans;
}
int read(){
bool minus=false;int x;char ch;
while(ch=getchar(),(ch>'9'||ch<'0')&&ch!='-');
if(ch=='-'){
minus=true;
ch=getchar();
}
x=ch-48;
while(ch=getchar(),ch<='9'&&ch>='0')x=x*10+ch-48;
return minus?-x:x;
}
int main(){
freopen("thebigmatch.in","r",stdin);
freopen("thebigmatch.out","w",stdout);
n=read();
for(int i=1;i<=n;++i)h[i]=read();
for(int i=1;i<=n;++i)d[i]=read();
int q=read();
int flag,l,r,w;
while(q--){
flag=read();
if(flag==1){
printf("%d",h[1]+getsum1(1)*d[1]-getsum2(1));
for(int i=2;i<=n;++i){
printf(" %d",h[i]+getsum1(i)*d[i]-getsum2(i));
}
putchar('\n');
}
else{
l=read();r=read();w=read();
for(int i=l;i<=n;i+=(i&-i))c2[i]+=w;
for(int i=r+1;i<=n;i+=(i&-i))c2[i]-=w;
for(int i=l;i<=n;i+=(i&-i))c1[i]++;
for(int i=r+1;i<=n;i+=(i&-i))c1[i]--;
}
}
fclose(stdin);fclose(stdout);
return 0;
}