Soldier Kill (a) time limit: +Ms | Memory Limit:65535KB Difficulty:3
-
-
Describe
-
South Generals have n soldiers, numbered 1 to N, each of these soldiers is known for their kills.
The boy is the South General's military advisers, the South General now want to know the number M to No. N soldiers total kills, please help the handyman to answer the South General.
Note that the South General may ask many questions.
-
-
Input
-
-
only one set of test data
The first line is two integer n,m, where N represents the number of soldiers (1<n<1000000), and M indicates the number of times the South General inquired (1<M<100000)
The next line is n integers, and AI represents the number of soldier kills. (0<=ai<=100)
The subsequent M-line has two integer m,n per line, indicating that the general South wants to know the total number of kills (1<=m,n<=n) of soldiers from number m to nth.
-
-
Output
-
-
for each query, the total number of kills is output
One row per output
-
-
Sample input
-
-
5 21 2 3 4 51 32 4
-
-
Sample output
-
-
69
-
-
Soldier Kills (i)