BestCoder Round #91-B.Lotus and Horticulture(尺取法)
来源:互联网 发布:win7 网络脱机状态 编辑:程序博客网 时间:2024/06/03 20:52
记录一个菜逼的成长。。
题目链接
官方题解
首先考虑应该尝试选择哪些点:区间的左右端点、与区间左右端点距离0.5的点,这样就一定可以包括所有情况。 为了方便处理与区间左右端点距离0.5的点,只要将所有坐标扩大一倍,然后这些点就变成了“与区间左右端点距离1的点”了 考虑选出这些点后如何进行统计。显然先要将可以选的位置进行离散。假如我们选择的温度一开始是负无穷,这时答案是所有的c之和,考虑选择的温度不断升高,答案会如何变化。 每当选定的温度达到一个区间x的左端点时,答案加上
#include <cstdio>#include <iostream>#include <algorithm>using namespace std;#define fi first#define se secondtypedef long long LL;typedef pair<int,int> PII;const int maxn = 100000 + 10;PII p[maxn];int main(){ ios::sync_with_stdio(false); cin.tie(0); int T;cin>>T; while(T--){ int n,ind = 0; cin>>n; int l,r,a,b,c; LL sum = 0; for( int i = 1; i <= n; i++ ){ cin>>l>>r>>a>>b>>c; sum += c; p[ind].fi = l*2,p[ind++].se = a - c; p[ind].fi = r*2+1,p[ind++].se = b - a; } sort(p,p+ind); LL ans = sum; for( int i = 0,j = 0; i < ind; i++ ){ while(j < ind && p[j].fi == p[i].fi){sum += p[j++].se;} ans = max(ans,sum); } cout << ans << endl; } return 0;}
0 0
- BestCoder Round #91-B.Lotus and Horticulture(尺取法)
- BestCoder#91Lotus and Horticulture
- [Bestcoder Round#91][HDU6012] Lotus and Horticulture 排序
- BestCoder Round #91 1001 (HDU 6011 Lotus and Characters) 1002 (HDU 6012 Lotus and Horticulture)
- hdu6012(bestcoder 91) Lotus and Horticulture(离散化+前缀和)
- Lotus and Horticulture
- Lotus and Horticulture
- BestCoder Round #91-A .Lotus and Characters(贪心)
- HDU6012 Lotus and Horticulture 扫描
- HDU 6012 Lotus and Horticulture
- HDOJ 6012 Lotus and Horticulture
- hdu 6012 Lotus and Horticulture
- HDU 6012 Lotus and Horticulture
- Lotus and Horticulture(贪心)
- hdu 6012 Lotus and Horticulture
- BestCoder#91Lotus and Characters
- BestCoder Round #85 sum(尺取法)
- BestCoder Round #86 1003(尺取法)
- DIJKSTRA程序算法示例
- Android开发人员不得不收集的代码
- 子进程和线程的区别
- Spring Security(02)——关于登录
- 权威指南中Maxtemperature
- BestCoder Round #91-B.Lotus and Horticulture(尺取法)
- Hadoop中dataNode启动不了
- JDBC获取记录总数
- HttpClient java发送网络请求的学习
- Domino登录时,domcfg中表单的reasonType值含义
- 二叉树的前序遍历
- Node.js基础学习2
- 微信小程序开发之选择器 时间选择器 日期选择器 地区选择器
- lower(upper)_bound