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; +}