#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;
}
System Design for Beginners
A masterclass that helps early engineers and product managers become great at designing scalable systems.
180+ learners
Details →System Design Masterclass
A masterclass that helps you become great at designing scalable, fault-tolerant, and highly available systems.
1000+ learners
Details →Redis Internals
Learn internals of Redis by re-implementing some of the core features in Golang.
98+ learners
Details →