RingTouSou @ 2023-10-30 20:52:08
#include<bits/stdc++.h>
using namespace std;
const int N=5000010;
int a[N],b[N];
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int n,p;
cin>>n>>p;
for(int i=1;i<=n;++i)
{
cin>>a[i];
}
for(int i=1;i<=n;++i)
{
b[i]=a[i]-a[i-1];
}
while(p--)
{
int x,y;
cin>>x>>y;
int k;
cin>>k;
b[x]+=k;
b[y+1]-=k;
}
int min=1e9;
for(int i=1;i<=n;++i)
{
b[i]+=b[i-1];
if(min>b[i])
{
min=b[i];
}
}
cout<<min;
return 0;
}
by GXZJQ @ 2023-12-01 12:45:21
我也用的是sort,但可以直接过,不知道为啥