2017-10-30 16:27

Hun Gui Wei Company

  • numbers
  • gui
  • lines
  • each

Problem Description
My friend Hun Gui Wei (HGW) has started a company which is named Hun Gui Wei Company (HGWC). In HGWC, there are many staffs. Every staff has a certain salary, level and working age. Sometimes, HGW wants to do some queries. He wants to know the sum of salary of the staffs fit some conditions. For the large amount of staffs, artificial query is time-consuming. So he wants to hire you to write a program to help him. If you do a good job, he will pay you a generous remuneration.

Multi test cases (about 10).
The first line contains an integer n indicates there are n staffs in HGWC.
In the next n lines, each line describes the attributes of one staff.
Each line contains S, L, A indicate the salary, level and working age of one staff.
Next line an integer m comes which indicates there will be m queries.
Then next m lines, query dates will come
HGW sets a variable k. In the beginning of each test case, k = 0. For the i-th query, he sets
LLi=LLi+k,HLi=HLi−k,LAi=LAi+k,HAi=HAi−k, then make k the answer of this query.

[Technical Specification]
All numbers in the input are integers.

For i-th query,output the sum of salary of the staffs whose level are between LLi and HLi while working age are between LAi and HAi in a single line.

Sample Input
1 2 3
4 5 6
3 2 3 3
2 6 2 7

Sample Output

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享