提交时间:2023-11-23 21:08:03
运行 ID: 31771
#include<bits/stdc++.h> using namespace std; int sub[5000005]; int a,b; int n,k; int ans = 0x3f3f3f3f; inline int read(){ char ch = getchar();int x = 0, f = 1; while(ch<'0'||ch>'9'){if(ch == '-') f = -1;ch = getchar();} while('0'<=ch && ch <= '9'){x = x*10+ch-'0';ch = getchar();} return x*f; } int main() { n = read(),k = read(); for(int i = 1;i<=n;++i) { a = read(); sub[i] = a-b; b = a; } for(int i = 1;i<=k;++i) { int x = read(),y = read(),z = read(); sub[x]+=z;sub[y+1]-=z; } for(int i = 1;i<=n;++i) { sub[i] += sub[i-1]; ans = min(ans,sub[i]); } cout<<ans<<endl; return 0; }