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 }
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超时的一天 看了别人的才写出来