Submission

Status:

PPPPPPPPPPPPPPPPPPPP

Score: 100

User: Winzzwz

Problemset: ผลบวก (กลาง)

Language: cpp

Time: 0.065 second

Submitted On: 2024-11-10 23:10:22

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int dp[1000100];
int n,q,x,y;
int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> dp[i];
        if (i > 0) dp[i] += dp[i-1];
    }
    cin >> q;
    while (q--) {
        cin >> x >> y;
        cout << dp[y]-dp[x-1] << "\n";
    }
    return 0;
}