-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTesting.java
More file actions
54 lines (33 loc) · 1.12 KB
/
Testing.java
File metadata and controls
54 lines (33 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class Testing{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
long m = sc.nextLong();
long arr[] = new long[n];
for(int j = 1 ; j <= m ; j++){
int a = sc.nextInt();
int b = sc.nextInt();
int k = sc.nextInt();
arr[a] += k;
if(b < n){
arr[b+1] -= k;
}
}
long sum = arr[1];
long max = arr[1];
for(int i = 2; i < n + 1 ; i++){
sum =sum + arr[i];
if(max < sum){
max = sum;
}
}
System.out.println(max);
}
}