For this Question: A company is formed over N years. The company has sold X products (numbered through 1 to X) over the span of N years.
For every product, company has noted 3 integers a, b, and c.
It means the company gained a profit of "c" from years "a" to "b" (inclusive of both) where 1<=a<=b<=N. (Note: The company gained the profit "c" every year in the given range).
After updating all the profits your task is to calculate the maximum sum of profits over any contiguous range of years.
Note: Profit value can be negative.
For better understanding see the example.First line of input contains two integers N and X
Next X lines contains three integers a,b,c starting year ,ending year and the profit value

Constraints:-
1<=N, X<=10^5
-10^5<=c<=10^5
1<=a<=b<=NPrint a single integer containing the maximum sum of profit value over contiguous years.Sample Input:-
4 3
1 3 5
2 4 6
1 2 -10

Sample Output:-
18

Explanation:-
After updating the products , The final profits values over N years are: -5 1 11 6
maximum sum=18 (1+11+6), I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {
	public static void main (String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		StringTokenizer st= new StringTokenizer(br.readLine());
		int n= Integer.parseInt(st.nextToken());
		int x= Integer.parseInt(st.nextToken());

		int[] arr = new int[n+1];

		for(int i=1; i<=x; i++){
			StringTokenizer st1= new StringTokenizer(br.readLine());
			int a= Integer.parseInt(st1.nextToken());
			int b= Integer.parseInt(st1.nextToken());
			int c= Integer.parseInt(st1.nextToken());


			for(int j=a; j<=b; j++){
				arr[j]+= c;
			}

		}


		long currMax=0, maxSoFar=0, maxNo=Integer.MIN_VALUE;
		for(int i=1; i<=n; i++){

			long val= arr[i];
			currMax+= val;

			if(currMax > maxSoFar)
				maxSoFar = currMax;

			if(currMax<0)
				currMax =0;

			if(maxNo< val){
				 maxNo= val;
			}
		}

	    if(maxSoFar>0)
			System.out.println(maxSoFar);
		else{
			System.out.println(maxNo);
		}


	}
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?