Skip to content

Commit 1e9e11a

Browse files
authored
[20251019] BOJ / G5 / 태상이의 훈련소 생활 / 김수연
[20251019] BOJ / G5 / 태상이의 훈련소 생활 / 김수연
2 parents d8453af + f0ba6b8 commit 1e9e11a

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
```

0 commit comments

Comments
 (0)