From 14308b5cfd7e9b12e5ab24d8c757468c11df9bce Mon Sep 17 00:00:00 2001 From: Baoshuo Ren Date: Wed, 1 Dec 2021 17:23:11 +0800 Subject: [PATCH] =?UTF-8?q?797.=20=E5=B7=AE=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acwing.com/problem/content/submission/code_detail/9150952/ --- AcWing/797/797.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 AcWing/797/797.cpp diff --git a/AcWing/797/797.cpp b/AcWing/797/797.cpp new file mode 100644 index 00000000..bd9fae3b --- /dev/null +++ b/AcWing/797/797.cpp @@ -0,0 +1,27 @@ +#include + +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; +}