一道简单的差分板子题
#include <iostream>
using namespace std;
const int N = 5e6+10;
int a[N];
int n,p;
int f[N];
int main()
{
cin >> n >> p;
for(int i = 1;i<=n;i++)
{
cin >> a[i];
f[i] = a[i]-a[i-1];
}
while(p--)
{
int x,y,z;cin >> x >> y >> z;
f[x]+=z;
f[y+1]-=z;
}
int ret = 110;
for(int i = 1;i<=n;i++)
{
f[i]=f[i-1]+f[i];
ret = min(ret,f[i]);
}
cout << ret << endl;
return 0;
}