Soldier Kills (i)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.