#include <cstdio>
#include <iostream>
long long int arr[10000010];
int main() {
int n, t;
int a, b;
long long int k;
scanf("%d %d", &n, &t);
for (int i = 0; i < t; i++) {
scanf("%d %d %lld", &a, &b, &k);
arr[a] += k;
arr[b+1] -= k;
}
long long int max = INT64_MIN, sum = 0;
for (int i = 1; i <= n; i++) {
sum += arr[i];
max = sum > max ? sum : max;
}
printf("%lld\n", max);
return 0;
}
Arpit's Newsletter read by 15000+ engineers
🔥 Thrice a week, in your inbox, an essay about system design, distributed systems, microservices, programming languages internals, or a deep dive on some super-clever algorithm, or just a few tips on building highly scalable distributed systems.