Both Ends Of The Range

Following the Competitive Programmer's Handbook convention, p[k] holds a0+a1+⋯+aka_0 + a_1 + \dots + a_k, and sum(a,b)=p[b]−p[a−1]\text{sum}(a, b) = p[b] - p[a-1] with p[−1]p[-1] defined as 0.

index 0 1 2 3 4 5 6 7
a[i] 5 2 9 1 7 3 8 4
p[i] 5 7 16 17 24 27 35 39

Evaluate sum(2,5)\text{sum}(2, 5) and sum(0,2)\text{sum}(0, 2), in that order.

A

11 and 11

B

20 and 16

C

11 and 16

D

20 and 11