30分求求,TLE,悬关
查看原帖
30分求求,TLE,悬关
681893
DANXIBAO_Hhh楼主2024/8/2 13:32
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
long long n,p,s,t,a[N],cha[N],sum[N];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>p>>s>>t;
	for(int i=0;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) cha[i]=a[i]-a[i-1];
	for(int i=1;i<=p;i++){
		long long l,r,z;
		cin>>l>>r>>z;
		cha[l]+=z;
		cha[r+1]-=z;
		long long b=0;
		for(int j=1;j<=n;j++){
			if(cha[j]<0) b+=t*abs(cha[j]);
			else b-=s*abs(cha[j]);
		}
		cout<<b<<endl;
	}
	return 0;
}

不知道怎么优化了

求求大佬帮助啊

2024/8/2 13:32
加载中...