国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

HDU 6012

2019-11-14 13:00:33
字體:
來源:轉載
供稿:網友

Lotus and Horticulture Time Limit: 4000/2000 MS (java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 692 Accepted Submission(s): 220

PRoblem Description 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 n 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], 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 ai units of research value; if the growth temperature exceeds the upper limit of the suitable temperature, it can provide the bi units of research value; temperatures below the lower limit of the appropriate temperature, can provide ci units of research value.

Now, through experimentation, Lotus has known the appropriate growth temperature range for each plant, and the values of a, b, c 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.

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

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

The next n line, each line contains five integers li,ri,ai,bi,ci∈[1,109].

Output For 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

Source BestCoder Round #91

貪心即可,假設溫度從負無窮大開始遞增,于是首先算出所有植物C情況之和,然后對每個點進行排序,如果是L點,則-C+A,如果是R點,則-A+B,同時有兩點要注意:1,值相同的點。2.值相同時L,R不同怎么處理,在排序時應先對值排序,如果值相同的情況下,要優先L,然后R。

#include<bits/stdc++.h>using namespace std;struct plant{ long long lor; long long i; long long l; long long r; long long a,b,c;}p[200005];bool cmp(plant a,plant b){ return a.i==b.i?a.lor<b.lor:a.i<b.i;}int main(){ long long t,n,l,r,a,b,c; cin>>t; while(t--) { cin>>n; long long ans=0; for(long long i=0;i<n;i++) { scanf("%lld%lld%lld%lld%lld",&l,&r,&a,&b,&c); p[i*2].i=l,p[i*2+1].i=r; p[i*2].lor=0,p[i*2+1].lor=1; p[i*2].l=p[i*2+1].l=l; p[i*2].r=p[i*2+1].r=r; p[i*2].a=p[i*2+1].a=a; p[i*2].b=p[i*2+1].b=b; p[i*2].c=p[i*2+1].c=c; ans+=c; } sort(p,p+n*2,cmp); long long sum=ans; for(long long i=0;i<2*n;i++) { i--; do { i++; if(p[i].lor) { ans-=p[i].a; ans+=p[i].b; } else { ans-=p[i].c; ans+=p[i].a; } }while(p[i+1].i==p[i].i&&p[i+1].lor==p[i].lor); sum=max(ans,sum); } cout<<sum<<endl; }}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 依兰县| 宣城市| 久治县| 枣强县| 鸡西市| 青州市| 鲁山县| 遵化市| 枞阳县| 关岭| 民县| 当阳市| 定日县| 江达县| 曲水县| 博湖县| 墨竹工卡县| 绩溪县| 巴楚县| 青浦区| 岢岚县| 天峻县| 威宁| 东乌珠穆沁旗| 英山县| 海南省| 武威市| 清水河县| 仁怀市| 崇礼县| 巨鹿县| 万全县| 洪雅县| 全州县| 班戈县| 上栗县| 灌阳县| 阳江市| 云浮市| 万山特区| 庄河市|