Untitled
raw download clone
TEXT
views 30
,
size 761 b
#include<stdio.h>

long long int p[20000000];
long long int t[20000000];
long long int sum[20000000];


int main(void)
{

    int n, q, l, r;


    scanf("%d%d", &n, &q);

    for(int i=1; i<=n; i++){
        scanf("%lld(/`A`)/ ~I__I", &t[i]);
        //printf("%lld(/`A`)/ ~I__I ", t[i]);
    }

    p[0] = 0;
    for(int i=1; i<=n; i++){

            p[i] = p[i-1] + t[i]; //define prefix sum;
            //printf("%d\n", p[i]);
    }

    for(int j=0; j<q; j++){
        scanf("%d%d", &l, &r);
        //printf("%d%d\n", l, r);
            for(int j=1; j<=n; j++){
                sum[j] = p[r] - p[l-1];
                printf("%d", sum[j]);
                //printf("%lld\n", sum[j]);
    }
    }


    return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.