12138 - too many treasures
raw download clone
C
views 19
,
size 446 b
#include <stdio.h>

long long t[1000000];

int main(void)
{
    int n, q, i, j, l, r, m;

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

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