编程介的小学生 2017-03-29 14:02 采纳率: 20.5%
浏览 720
已采纳

Farming

Task

You have a big farm, and you want to grow vegetables in it. You're too lazy to seed the seeds yourself, so you've hired n people to do the job for you. Each person works in a rectangular piece of land, seeding one seed in one unit square. The working areas of different people may overlap, so one unit square can be seeded several times. However, due to limited space, different seeds in one square fight each other -- finally, the most powerful seed wins. If there are several "most powerful" seeds, one of them win (it does not matter which one wins).

There are m kinds of seeds. Different seeds grow up into different vegetables and sells for different prices. As a rule, more powerful seeds always grow up into more expensive vegetables. Your task is to calculate how much money will you get, by selling all the vegetables in the whole farm.

Input

The first line contains a single integer T (T <= 10), the number of test cases. Each case begins with two integers n, m (1 <= n <= 30000, 1 <= m <= 3). The next line contains m distinct positive integers pi (1 <= pi <= 100), the prices of each kind of vegetable. The vegetables (and their corresponding seeds) are numbered 1 to m in the order they appear in the input. Each of the following n lines contains five integers x1, y1, x2, y2, s, indicating a working seeded a rectangular area with lower-left corner (x1,y1), upper-right corner (x2,y2), with the s-th kind of seed. All of x1, y1, x2, y2 will be no larger than 106 in their absolute values.
Output

For each test case, print the case number and your final income.
Sample Input

2
1 1
25
0 0 10 10 1
2 2
5 2
0 0 2 1 1
1 0 3 2 2
Sample Output

Case 1: 2500
Case 2: 16

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-04-07 14:52
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog