lezhha @ 2023-04-20 12:40:25
#include<bits/stdc++.h>
using namespace std;
int n,p,x,y,z,t,ans;
int fs[5000005];
int a[5000005];
int main(){
cin>>p>>n;
ans=200000000;
for(int i=1;i<=p;i++)
scanf("%d",&fs[i]);
for(int i=1;i<=n;i++)
{
scanf("%d%d%d",&x,&y,&z);
a[x]+=z;a[y+1]-=z;
}
for(int i=1;i<=n;i++)
{
t+=a[i];
if(t+fs[i]<ans) ans=t+fs[i];
}
cout<<ans;
return 0;
}
by ieeqwq @ 2023-04-20 14:33:15
@lezhha 最后一个循环 n 换成 p
by lezhha @ 2023-04-21 12:21:45
感谢,已AC