LxSmill @ 2023-09-10 19:50:58
#include<bits/stdc++.h>
using namespace std;
const int N=5000010;
int n,p,x,y,z,ans=220,sum,a[N];
int main()
{
cin>>n>>p;
for(int i=1;i<=n;i++) cin>>a[i],a[i]-=a[i-1];
for(int i=1;i<=p;i++) cin>>x>>y>>z,a[x]+=z,a[y+1]-=z;
for(int i=1;i<=n;i++) sum+=a[i],ans=min(ans,sum);
cout<<ans<<endl;
return 0;
}
by linzijie22 @ 2023-09-10 20:11:37
你一开始算差分就算错了,按样例来说,最终得分应该是2 3 2,你的是2 3 3
by Smiog @ 2023-09-20 13:13:34
@LxSmill 成绩数组