poj2482 Stars in Your Window】的更多相关文章

Fleeting time does not blur my memory of you. Can it really be 4 years since I first saw you? I still remember, vividly, on the beautiful Zhuhai Campus, 4 years ago, from the moment I saw you smile, as you were walking out of the classroom and turned…
Stars in Your Window Language:Default Stars in Your Window Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 15036 Accepted: 4061 Description Fleeting time does not blur my memory of you. Can it really be 4 years since I first saw you? I sti…
Fleeting time does not blur my memory of you. Can it really be 4 years since I first saw you? I still remember, vividly, on the beautiful Zhuhai Campus, 4 years ago, from the moment I saw you smile, as you were walking out of the classroom and turned…
此题可用线段树或静态二叉树来做. 考虑用线段树: 很容易想到先限定矩形横轴范围再考虑在此纵轴上矩形内物品总价值的最大值. 那么枚举矩形横轴的复杂度是O(n)的,考虑如何快速获取纵轴上的最大值. 我们不可能再次枚举纵轴,依次统计,这样做事多余的. 考虑窗口在纵轴上的滑动,每上升到一个新的高度,在加入新元素的同时只需将最底层的那些值弹出队列即可. 这样我们需要考虑队列上元素和的最大值. 我们从反面考虑每个元素对特定队列(矩形纵轴位置)的贡献. 枚举窗口的上面一条边,那么元素对窗口贡献正值当且仅当H(…
题面 Poj 题解 下面内容引用自"李煜东 <算法竞赛进阶指南>"(对原文略有缩减,侵删): 因为矩形的大小固定,所以矩形可以由它的任意一个顶点唯一确定.我们可以考虑把矩形的右上角顶点放在什么位置,圈住的星星亮度总和最大. 所以,对于一颗星星,能够覆盖住这颗星星的右上角的位置在区间\([x,y]-[x+w,y+h]\)之间,但是由于边界上的星星不算,所以不妨将星星变为\([x-0.5,y-0.5]\),于是右上角变为\([x+w-1,y+h-1]\). 问题就转化成了:平面…
[POJ2482]Stars in Your Window 题面 vjudge 题解 第一眼还真没发现这题居然™是个扫描线 令点的坐标为\((x,y)\)权值为\(c\),则 若这个点能对结果有\(c\)的贡献,必须要矩形左下角的点的范围必须在\(([x,x+w),[y,y+h))\)之间 则按扫描线套路将一个类似矩形的范围拆成线\((x,y1,y2,c)\).\((x+w,y1,y2,-c)\)(依次表示横坐标.下端点纵坐标.上端点纵坐标.权值)即可 最后注意排序时不但要按\(x\)排,也要按…
Stars in Your Window Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11706   Accepted: 3183 Description Fleeting time does not blur my memory of you. Can it really be 4 years since I first saw you? I still remember, vividly, on the beaut…
Description Fleeting time does not blur my memory of you. Can it really be 4 years since I first saw you? I still remember, vividly, on the beautiful Zhuhai Campus, 4 years ago, from the moment I saw you smile, as you were walking out of the classroo…
1208 Stars in Your Window 题目来源: Poj 基准时间限制:2 秒 空间限制:131072 KB 分值: 160 难度:6级算法题  收藏  取消关注 整点上有N颗星星,每颗星星有一个亮度.用一个平行于x轴和y轴,宽为W高为H的方框去套星星.套住的所有星星的亮度之和为S(包括边框上的星星),求S的最大值. Input 第1行:共3个数N, W, H,中间用空格分割,N为星星的数量,W为方框的宽度,H为方框的高度.(2 <= N <= 50000, 1 <= W,…
Stars in Your Window   Description Fleeting time does not blur my memory of you. Can it really be 4 years since I first saw you? I still remember, vividly, on the beautiful Zhuhai Campus, 4 years ago, from the moment I saw you smile, as you were walk…