编程介的小学生 2017-10-30 16:27 采纳率: 20.5%
浏览 685
已采纳

Hun Gui Wei Company

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.

Input
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
LL0LL1⋮LLm−1HL0HL1⋮HLm−1LA0LA1⋮LAm−1HA0HA1⋮HAm−1
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.
1≤n,m≤105
0≤S,L,A≤109
−1017≤LLi,HLi,LAi,HAi≤1017

Output
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
2
1 2 3
4 5 6
2
3 2 3 3
2 6 2 7

Sample Output
1
4

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-11-23 02:28
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示