HE240214 @ 2024-07-25 09:15:52
#include<bits/stdc++.h>
using namespace std;
const int N=1e5;
int n,m;
int a[N],b[N];
int main() {
int n,m,min=1e9;
cin>>n>>m;
for(int i=1; i<=n; i++) {
cin>>a[i];
b[i]=a[i]-a[i-1];
}
int l,r,c;
while(m--) {
cin>>l>>r>>c;
b[l]+=c;
b[r+1]-=c;
}
for(int i=1; i<=n; i++) {
b[i]+=b[i-1];
if(b[i]<=min) {
min=b[i];
}
}
cout<<min;
return 0;
}
by abc1234shi @ 2024-07-25 09:21:35
@wuyifan2013 n<=5*1e6,你只开了1e5
by HE240214 @ 2024-07-25 09:22:24
@abc1234shi okok我试试
by abc1234shi @ 2024-07-25 09:23:31
@wuyifan2013 还要*5。
by HE240214 @ 2024-07-25 09:23:50
@abc1234shi 对了对了 谢谢 关了
by abc1234shi @ 2024-07-25 09:24:27
@wuyifan2013 谢谢,已互关