cx2013 @ 2024-06-15 10:25:26
#include<bits/stdc++.h>
using namespace std;
int a[10005],d[10005];
int main(){
int n,p;
cin>>n>>p;
for(int i=1;i<=n;++i){
cin>>a[i];
d[i]=a[i]-a[i-1];
}
for(int i=1;i<=p;++i){
int x,y,z;
cin>>x>>y>>z;
d[x]+=z;
d[y+1]-=z;
}
int minn=INT_MAX,t=0;
for(int i=1;i<=n;++i){
t+=d[i];
minn=min(t,minn);
}
cout<<minn;
return 0;
}
by shgzy32 @ 2024-06-15 10:29:14
注意n≤5×10^6,你数组开小了
by shgzy32 @ 2024-06-15 10:30:43
@cx2013 悬不悬关
by pengluming @ 2024-06-15 12:15:30
要注意一下数据范围,把数组改成5*10^6+10就可以了
by abc20131113 @ 2024-07-15 20:51:57
要注意一下数据范围,把数组改一下就好了