Skip to content

Commit 3e9e1dc

Browse files
authored
[20250817] BOJ / G5 / 태상이의 훈련소 생활 / 권혁준
1 parent e8ed5b8 commit 3e9e1dc

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
```cpp
2+
#include <bits/stdc++.h>
3+
using namespace std;
4+
5+
int main() {
6+
cin.tie(0)->sync_with_stdio(0);
7+
8+
int N, M, a[100001]{}, b[100001]{};
9+
cin>>N>>M;
10+
for(int i=1;i<=N;i++) cin>>a[i];
11+
for(int x,y,z;M--;) {
12+
cin>>x>>y>>z;
13+
b[x] += z;
14+
b[y+1] -= z;
15+
}
16+
int s = 0;
17+
for(int i=1;i<=N;i++) {
18+
s += b[i];
19+
cout<<a[i]+s<<' ';
20+
}
21+
22+
}
23+
```

0 commit comments

Comments
 (0)