AlenLuo @ 2023-08-13 21:18:02
这是代码
#include <cstdio>
#include <iostream>
using namespace std;
int n,p,x,y,z,m=1145,c[5000000],h[5000000],a[5000000];
int main(){
scanf("%d %d",&n,&p);
for(int i=1;i<=n;i++){
scanf("%d",&c[i]);
a[i]=c[i]-c[i-1];
}
for(int i=0;i<p;i++){
scanf("%d %d %d",&x,&y,&z);
a[x]+=z;
a[y+1]-=z;
x=0;
y=0;
z=0;
}
for(int i=1;i<=n;i++){
h[i]=a[i]+h[i-1];
if(h[i]<m)m=h[i];
}
printf("%d",m);
return 0;
}
by xs_siqi @ 2023-08-13 21:26:33
@Mrli1053 数组开小了
by xs_siqi @ 2023-08-13 21:27:57
by AlenLuo @ 2023-08-18 16:39:25
@xs_siqi 感谢~