#include

int main(){
    int size, q, n, sum;
    int left, right;
    scanf("%d %d", &size, &q);
    int accum[size+1];
    accum[0] = 0;
    for(int i=1; i         scanf("%d", &n);
        accum[i] = accum[i-1] + n;
    }

    while(q-- > 0){
        scanf("%d %d", &left, &right);
        if(left>right || (left>size || right>size))
            return -1;
        sum = accum[right] - accum[left-1];
        sum = (int)(sum /(right - left + 1));
        printf("%d\n", sum);
    }
}

 

 

 문제는 이거.


You are given an array of n numbers and q queries. For each query you have to print the floor of the expected value(mean) of the subarray from L to R.

Input:

First line contains two integers N and Q denoting number of array elements and number of queries.

Next line contains N space seperated integers denoting array elements.

Next Q lines contain two integers L and R(indices of the array).

Output:

print a single integer denoting the answer.

Constraints :

1<= N ,Q,L,R <= 10^6

1<= Array elements <= 10^9

 

 

컴파일은 되고, time error도 안나고 O(n^2)되는것도 피했는데

 

어디서 문제가 생긴걸까..