Fkxxx @ 2023-07-10 09:55:12
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n , q , a[500005] , d[5000005] , ans = 1e18 ;
signed main(){
cin >> n >> q ;
for( int i = 1 ; i <= n ; i ++ ){
cin >> a[i] ;
d[i] = a[i] - a[i - 1] ;
}
for( int i = 1 ; i <= q ; i ++ ){
int x , y , z ;
cin >> x >> y >> z ;
d[x] += z ;
d[y + 1] -= z ;
}
for( int i = 1 ; i <= n ; i ++ ){
d[i] += d[i - 1] ;
ans = min( ans , d[i] ) ;
}
cout << ans ;
return 0 ;
}
by YangJZHello @ 2023-07-26 18:20:47
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
加上这个