编程介的小学生 2018-11-28 08:39 采纳率: 20.5%
浏览 269
已采纳

请问大家,这个问题用C语言的方式怎么才能解决呢?

Problem Description
There are N customers set their M different advertisements on Baidu. Each advertisement is owned by single customer. The ads system of Baidu records the number of clicks of each advertisement this year. The proposal system wants to analysis the advertisements about the relativity of the description length and the number of clicks of the advertisements. During the analysis, it is very important to do such a query to ask the total length of the advertisements with top k clicking times for each customer. You may assume the number of clicks of all advertisements are distinct.
Your task is to help Baidu to design this little toolkit.

Input
The input consist multiple test cases. The number of test cases is given in the first line of the input.
For each test case, the first line contains three integers N, M and Q, denoting the number customer, the number of advertisement instances and the number of queries. (N <= 100000, M <= 500000, Q <= 100000)
Then M lines follow, each line contains three numbers, U, C and L, indicating the owner of this advertisement, the clicks for this advertisement and the length. (1 <= U <= N, 0 <= C, L <= 1000000000)
Finally Q lines come. Each line contains only one integer k, representing the query for top k clicking advertisements for each customer.

Output
For each test case, output Q lines, each line contains only one integer, denoting the sum of total length of the top k number of clicks for each customer.

Sample Input
2
2 4 3
1 12 13
2 23 41
1 21 46
1 22 31
1
2
3
6 15 3
5 2677139 731358928
2 347112028 239095183
6 27407970 85994789
6 767687908 734935764
6 255454855 110193353
3 39860954 813158671
5 617524049 55413590
3 338773814 7907652
6 810348880 736644178
2 777664288 63811422
6 590330120 616490361
5 552407488 136492190
1 416295130 448298060
5 811513162 232437061
4 43273262 874901209
4
9
13

Sample Output
Case #1:
72
118
131
Case #2:
5801137622
5887132411
5887132411

  • 写回答

1条回答 默认 最新

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

报告相同问题?

悬赏问题

  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝