Lotus and Horticulture HDU - 6012

 1 #include <iostream>
 2 using namespace std;
 3 #include<string.h>
 4 #include<set>
 5 #include<stdio.h>
 6 #include<math.h>
 7 #include<queue>
 8 #include<map>
 9 #include<algorithm>
10 #include<queue>
11 #define ll long long
12 int t,n,l,r,d,b,c;
13 struct lll
14 {
15     int wendu,chazhi;
16     bool operator<(const lll &qwe)const
17     {
18         return wendu<qwe.wendu;
19     }
20 }a[100100];
21 
22 int main()
23 {
24     scanf("%d",&t);
25     while(t--)
26     {
27         scanf("%d",&n);
28         long long max1=0,sum=0;int add=0;
29         for(int i=1;i<=n;++i)
30         {
31             scanf("%d%d%d%d%d",&l,&r,&d,&b,&c);
32             sum+=c;
33             a[++add].wendu=l*2;
34             a[add].chazhi=d-c;
35             a[++add].wendu=r*2+1;
36             a[add].chazhi=b-d;
37         }
38         max1=sum;
39         sort(a+1,a+1+add);
40         int i;
41         for(i=1;i<=add;)
42         {
43           sum+=a[i].chazhi;
44           i++;
45           while(a[i].wendu==a[i-1].wendu)
46             {
47                 sum+=a[i].chazhi;
48                 i++;
49             }
50           max1=max(max1,sum);
51         }
52        cout<<max1<<endl;
53     }
54 }
View Code
These days Lotus is interested in cultivating potted plants, so she wants to build a greenhouse to meet her research desires. 

Lotus placed all of the  nn pots in the new greenhouse, so all potted plants were in the same environment. 

Each plant has an optimal growth temperature range of [l,r][l,r], which grows best at this temperature range, but does not necessarily provide the best research value (Lotus thinks that researching poorly developed potted plants are also of great research value). 

Lotus has carried out a number of experiments and found that if the growth temperature of the i-th plant is suitable, it can provide aiai units of research value; if the growth temperature exceeds the upper limit of the suitable temperature, it can provide the bibi units of research value; temperatures below the lower limit of the appropriate temperature, can provide cici units of research value. 

Now, through experimentation, Lotus has known the appropriate growth temperature range for each plant, and the values of aa, bb, cc are also known. You need to choose a temperature for the greenhouse based on these information, providing Lotus with the maximum research value. 

__NOTICE: the temperature can be any real number.__ 

InputThe input includes multiple test cases. The first line contains a single integer TT, the number of test cases. 

The first line of each test case contains a single integer n[1,50000]n∈[1,50000], the number of potted plants. 

The next nn line, each line contains five integers li,ri,ai,bi,ci[1,109]li,ri,ai,bi,ci∈[1,109]. 
OutputFor each test case, print one line of one single integer presenting the answer. 
Sample Input

1
5
5 8 16 20 12
10 16 3 13 13
8 11 13 1 11
7 9 6 17 5
2 11 20 8 5

Sample Output

83
超时的一天 看了别人的才写出来

转载于:https://www.cnblogs.com/dulute/p/7272707.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值