There are N villages on a number line. The i-th village is located at coordinate X i ,…
- User
There are N villages on a number line. The i-th village is located at coordinate X i , and has P i villagers.
Answer Q queries. The i-th query is in the following format:
Given integers L i and R i , find the total number of villagers living in villages located between coordinates L i and R i , inclusive. Constraints 1≤N,Q≤2×10 5
−10 9 ≤X 1 <X 2 <…<X N ≤10 9
1≤P i ≤10 9
−10 9 ≤L i ≤R i ≤10 9
All input values are integers. Input The input is given from Standard Input in the following format:
N X 1
… X N
P 1
… P N
Q L 1
R 1
⋮ L Q
R Q
Output Print Q lines.
The i-th line (1≤i≤Q) should contain the answer to the i-th query.
give in c++
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.