编程介的小学生 2017-04-02 07:54 采纳率: 20.5%
浏览 842
已采纳

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-12 15:35
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用