HUD.2795 Billboard ( 线段树 区间最值 单点更新 单点查询 建树技巧) 题意分析 题目大意:一个h*w的公告牌,要在其上贴公告. 输入的是1*wi的w值,这些是公告的尺寸. 贴公告要满足的条件: 1. 尽量往上,同一高度尽量靠左. 2. 求第n个广告所在的行数. 3. 没有合适的位置贴了则输出-1. 建树技巧 首先看了一下数据范围h和w都在1e9,按照高度建树不太现实的.但是发现询问只有2e5,.仔细想一下如果h < 2e5, 我们用h建树,否则用n建树.原因是,每个高度只放…
Billboard Time Limit: 20000/8000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 11861    Accepted Submission(s): 5223 Problem Description At the entrance to the university, there is a huge rectangular billboard of s…
Description At the entrance to the university, there is a huge rectangular billboard of size h*w (h is its height and w is its width). The board is the place where all possible announcements are posted: nearest programming competitions, changes in th…
Billboard Time Limit: 20000/8000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 16023    Accepted Submission(s): 6770 Problem Description At the entrance to the university, there is a huge rectangular billboard of s…
Billboard Time Limit: 20000/8000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 21203    Accepted Submission(s): 8750 Problem Description At the entrance to the university, there is a huge rectangular billboard of…
Billboard Time Limit: 20000/8000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 18496    Accepted Submission(s): 7751 Problem Description At the entrance to the university, there is a huge rectangular billboard of s…
题意 : 有一块 h * w 的公告板,现在往上面贴 n 张长恒为 1 宽为 wi 的公告,每次贴的地方都是尽量靠左靠上,问你每一张公告将被贴在1~h的哪一行?按照输入顺序给出. 分析 : 这道题说明了每一次贴都尽量选择靠上靠左的位置,那既然这样,我们以1~h建立线段树,给每一个叶子节点赋值初值 w 表示当前行最大能够容纳宽度为 w 的公告纸,那么对于某一输入 wi 只要在线段树的尽量靠左的区间找出能够容纳这张公告的位置(即叶子节点)然后减去 wi 即可,需要对query()函数进行一点改造,将…
手动博客搬家:本文发表于20170822 21:30:17, 原地址https://blog.csdn.net/suncongbo/article/details/77488127 URL: http://acm.hdu.edu.cn/showproblem.php?pid=2795题目大意:有一个h*w的木板 (h, w<=1e9), 现在有n (n<=2e5)张1*xi的海报要贴在木板上,按1~n的顺序每次贴海报时会选择最上的一排的最左边贴 (海报不能互相覆盖), 求每张海报会被贴在哪一行…
Billboard Time Limit: 20000/8000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10594    Accepted Submission(s): 4686 Problem Description At the entrance to the university, there is a huge rectangular billboard of s…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2795 题目大意:有一块h*w的矩形广告板,要往上面贴广告;   然后给n个1*wi的广告,要求把广告贴上去: 而且要求广告要尽量往上贴并且尽量靠左;  求每个广告的所在的位置,不能贴则为-1. 用线段树模拟,要是左子树的最大值比当前广告大,就查询更新左子树,否则就右子树. #include <iostream> #include <cstdio> #include <cstrin…