Segment Trees: coding problems
Write a program that reads the input and prints the answer. Run checks it against every test, including hidden ones.
0 of 7 solved
A coach keeps the season points of every player in one row, in roster order. Player 0 is the first player on the list. Each question asks for a block of players, from index
lto indexr, both included. Answer each question with the total points of that block. Build a segment tree over the points, or add up the block directly.Input. Line 1: `n`, the number of players (1 to 100000). Line 2: `n` points, each from 0 to 1000. Line 3: `q`, the number of questions (1 to 100000). Each of the next `q` lines: `l r` with 0 <= l <= r < n.
Output. One line per question: the total points of that block.
Example 1 input
5 3 9 2 9 7 2 0 2 1 4
Output
14 27
Example 2 input
3 5 0 5 3 0 0 0 1 0 2
Output
5 5 10