File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ ``` java
2+ import java.io.* ;
3+ import java.util.* ;
4+
5+ public class boj19951 {
6+ static BufferedReader br = new BufferedReader (new InputStreamReader (System . in));
7+ static StringTokenizer st;
8+ static void nextLine () throws Exception {st = new StringTokenizer (br .readLine ());}
9+ static int nextInt() {return Integer . parseInt(st. nextToken());}
10+ static StringBuilder sb = new StringBuilder ();
11+
12+ public static void main(String [] args) throws Exception {
13+ nextLine();
14+ int N = nextInt();
15+ int M = nextInt();
16+ int [] arr = new int [N + 1 ];
17+ nextLine();
18+ for (int i= 1 ; i< arr. length; i++ ) {
19+ arr[i] = nextInt();
20+ }
21+
22+ int [] dp = new int [N + 2 ];
23+ for (int t= 0 ; t< M ; t++ ) {
24+ nextLine();
25+ int start = nextInt();
26+ int end = nextInt();
27+ int k = nextInt();
28+
29+ dp[start] = dp[start]+ k;
30+ dp[end+ 1 ] = dp[end+ 1 ]- k;
31+ }
32+
33+ StringBuilder sb = new StringBuilder ();
34+ for (int i= 1 ; i< arr. length; i++ ) {
35+ dp[i] = dp[i]+ dp[i- 1 ];
36+ sb. append((arr[i]+ dp[i])+ " " );
37+ }
38+ System . out. println(sb. toString());
39+ }
40+ }
41+ ```
You can’t perform that action at this time.
0 commit comments