80pts 求调
  • 板块P2367 语文成绩
  • 楼主_Soil_
  • 当前回复11
  • 已保存回复11
  • 发布时间2023/7/10 09:55
  • 上次更新2023/11/3 10:49:25
查看原帖
80pts 求调
682248
_Soil_楼主2023/7/10 09:55
#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 ;
} 
2023/7/10 09:55
加载中...