MCPcopy Create free account
hub / github.com/E869120/math-algorithm-book / main

Function main

codes/cpp/Code_4_02_1.cpp:7–18  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5int Q, L[100009], R[100009];
6
7int main() {
8 // ���� �� �ݐϘa�����߂�
9 cin >> N >> Q;
10 for (int i = 1; i <= N; i++) cin >> A[i];
11 for (int j = 1; j <= Q; j++) cin >> L[j] >> R[j];
12 B[0] = 0;
13 for (int i = 1; i <= N; i++) B[i] = B[i - 1] + A[i];
14
15 // �����̏o��
16 for (int j = 1; j <= Q; j++) cout << B[R[j]] - B[L[j] - 1] << endl;
17 return 0;
18}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected