From 3e82fa10c71727ae3e1b60fc5adf8129702e90d5 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Thu, 22 Jul 2021 15:22:01 +0800 Subject: [PATCH] =?UTF-8?q?795.=20=E5=89=8D=E7=BC=80=E5=92=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acwing.com/problem/content/submission/code_detail/6604420/ --- AcWing/795/795.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 AcWing/795/795.cpp diff --git a/AcWing/795/795.cpp b/AcWing/795/795.cpp new file mode 100644 index 00000000..ca2b231a --- /dev/null +++ b/AcWing/795/795.cpp @@ -0,0 +1,18 @@ +#include + +using namespace std; + +int n, m, a, l, r, sum[100005]; + +int main() { + cin >> n >> m; + for (int i = 1; i <= n; i++) { + cin >> a; + sum[i] = sum[i - 1] + a; + } + for (int i = 1; i <= m; i++) { + cin >> l >> r; + cout << sum[r] - sum[l - 1] << endl; + } + return 0; +}