mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 21:08:47 +00:00
797. 差分
https://www.acwing.com/problem/content/submission/code_detail/9150952/
This commit is contained in:
parent
39cfc3b8c0
commit
14308b5cfd
27
AcWing/797/797.cpp
Normal file
27
AcWing/797/797.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
int n, m, l, r, c, b[100005];
|
||||
|
||||
int main() {
|
||||
cin >> n >> m;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> c;
|
||||
b[i] += c;
|
||||
b[i + 1] -= c;
|
||||
}
|
||||
while (m--) {
|
||||
cin >> l >> r >> c;
|
||||
b[l] += c;
|
||||
b[r + 1] -= c;
|
||||
}
|
||||
for (int i = 1; i <= n; i++) {
|
||||
b[i] += b[i - 1];
|
||||
cout << b[i] << ' ';
|
||||
}
|
||||
cout << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user