麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

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

HDU 6012

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

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; }}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 粉嫩粉嫩一区二区三区在线播放 | 一级一级一级一级毛片 | www.91成人 | 亚洲视频在线网 | 日韩中文字幕一区二区三区 | 视频一区免费观看 | 久久精品99北条麻妃 | 操碰网 | 欧美成人一区二区三区电影 | 日本欧美一区二区三区在线播 | 精品一区二区三区日本 | 一本色道久久综合狠狠躁篇适合什么人看 | 福利在线免费视频 | 久久亚洲网| 国产亚洲精品久久久久久久久久 | 国产电影精品久久 | 国产精品久久久免费看 | 精国品产一区二区三区有限公司 | 国产三级午夜理伦三级 | 国产成年人在线观看 | 久久人人爽人人爽人人片av高清 | 国产精品美女一区二区 | 久久情爱网 | 久久久青 | 日本成人一区二区 | 视频一区二区三区在线播放 | 免费一区二区三区 | 蜜桃一本色道久久综合亚洲精品冫 | 亚洲成人免费影视 | 精品成人av一区二区三区 | 深夜毛片免费看 | 美国人成人在线视频 | 91,视频免费看 | 久久99精品久久久久久国产越南 | 久久精品一二三区白丝高潮 | hd porn 4k video xhicial | 久久久一区二区三区精品 | 日美黄色片 | 性欧美性欧美 | 一日本道久久久精品国产 | 正在播放91|