Submission

Status:
PPPPPPPPPPPPPPPPPPPP

Score: 100

User: Asphyrv

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

Language: cpp

Time: 0.046 second

Submitted On: 2024-11-11 23:13:21

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll p[1000006];

int main(){
    cin.tie(NULL)->ios_base::sync_with_stdio(false);
    int n, a, x, y, q;
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> a;
        p[i] = p[i-1] + a;
        //cout << p[i] << ' ';
    }
    cin >> q;
    while(q--){
        cin >> x >> y;
        cout << p[y+1] - p[x] << '\n';
    }
    return 0;
}