import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
long arr[]=new long[n];
long m = in.nextLong();
for(int a0 = 0; a0 < m; a0++){
long a = in.nextLong();
long b = in.nextLong();
long k = in.nextLong();
for(int i=(int)a-1;i<(int)b;i++)
arr[i]+=k;
}
long large=-999;
for(int i=0;i<n;i++)
{ if(arr[i]>large)
large=arr[i];
}
System.out.println(large);
in.close();
}
}
this is my answer for " You are given a list(1-indexed) of size n, initialized with zeroes. You have to perform operations on the list and output the maximum of final values of all the n elements in the list. For every operation, you are given three integers a, b and k and you have to add value k to all the elements ranging from index a to b (both inclusive)." But I am getting "Timedout error" for half of it.Can anyone please pitch in some ideas here??