Untitled
raw download clone
C
views 28
,
size 508 b
#include <stdio.h>

long long pre[1000005];

int main(void)
{
    freopen("12138_sampleIn.txt", "r", stdin);

    int m, n, q, l, r, i;
    int crate_value;

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

    for(i = 1; i <= n; i++){
        scanf("%d", &crate_value);
        if(crate_value >= 0) pre[i] = pre[i-1] + crate_value;
        else pre[i] = pre[i-1];
    }

    for(i = 0; i < q; i++){
        scanf("%d%d%d",&l , &r, &m);
        printf("%lld\n", pre[l+m-1] - pre[l-1]);
    }

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