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

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

HDU 6012

2019-11-14 12:04:27
字體:
來源:轉載
供稿:網友

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; }}
上一篇:翻硬幣

下一篇:JNI資源釋放

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 汨罗市| 阿拉尔市| 天门市| 灌阳县| 伊吾县| 葵青区| 科技| 宕昌县| 内黄县| 石屏县| 定陶县| 渝北区| 萨嘎县| 湘西| 旌德县| 湛江市| 清远市| 青岛市| 大城县| 买车| 英山县| 同江市| 华蓥市| 土默特右旗| 巴塘县| 山东| 连城县| 济源市| 天水市| 黎川县| 昭平县| 内江市| 怀集县| 灌南县| 乌审旗| 藁城市| 文成县| 汨罗市| 汉阴县| 龙海市| 林西县|