Billboard 通过这题,我知道了要活用线段树的思想,而不是拘泥于形式, 就比如这题 显然更新和查询放在一起很简单 但如果分开写 那么我觉得难度会大大增加 [题目链接]Billboard [题目类型]区间求最大值的位置update的操作在query里做了 &题意: h*w的木板,放进一些1*L的物品,求每次放空间能容纳且最上边的位子 &题解: 思路:每次找到最大值的位子,然后减去L 线段树功能:query 区间求最大值的位置(直接把update的操作在query里做了) [时间复杂度]…
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…
HDU 2795 Billboard(宣传栏贴公告,线段树应用) ACM 题目地址:HDU 2795 Billboard 题意:  要在h*w宣传栏上贴公告,每条公告的高度都是为1的,并且每条公告都要尽量贴最上面最靠左边的,给你一系列的公告的长度,问它们能不能贴上. 分析:  不是非常好想,只是想到了就非常好写了.  仅仅要把宣传栏倒过来就好办了,这时候就是变成有h条位置能够填公告,填放公告时就能够尽量找最左边的合适的位置来放了.  能够用线段树实现,查找的复杂度是O(logn),须要注意的坑点…
题意 : 有一块 h * w 的公告板,现在往上面贴 n 张长恒为 1 宽为 wi 的公告,每次贴的地方都是尽量靠左靠上,问你每一张公告将被贴在1~h的哪一行?按照输入顺序给出. 分析 : 这道题说明了每一次贴都尽量选择靠上靠左的位置,那既然这样,我们以1~h建立线段树,给每一个叶子节点赋值初值 w 表示当前行最大能够容纳宽度为 w 的公告纸,那么对于某一输入 wi 只要在线段树的尽量靠左的区间找出能够容纳这张公告的位置(即叶子节点)然后减去 wi 即可,需要对query()函数进行一点改造,将…
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=2795 Billboard Time Limit: 20000/8000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 28743    Accepted Submission(s): 11651 Problem Description At the entrance to the un…
Billboard Time Limit:8000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 2795 Appoint description:  System Crawler  (2015-04-10) Description At the entrance to the university, there is a huge rectangular billb…
Billboard Time Limit: 20000/8000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 19225    Accepted Submission(s): 8042 Problem Description At the entrance to the university, there is a huge rectangular billboard of…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2795 Billboard Time Limit: 20000/8000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 13050    Accepted Submission(s): 5651 Problem Description At the entrance to the un…
手动博客搬家:本文发表于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的顺序每次贴海报时会选择最上的一排的最左边贴 (海报不能互相覆盖), 求每张海报会被贴在哪一行…
HDU   1754 Description 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某到某某当中,分数最高的是多少. 这让很多学生很反感. 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问.当然,老师有时候需要更新某位同学的成绩.   Input 本题目包含多组测试,请处理到文件结束. 在每个测试的第一行,有两个正整数 N 和 M ( 0<N<=200000,0<M<5000 ),分别代表学生的数目和操作的数目. 学生ID编号分别从1编到…
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…
I Hate It Time Limit:3000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1754 Description 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某到某某当中,分数最高的是多少. 这让很多学生很反感. 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问.当然,老师有时候需要更新某位同学的成绩.   In…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2795 题目大意:有一块h*w的矩形广告板,要往上面贴广告;   然后给n个1*wi的广告,要求把广告贴上去: 而且要求广告要尽量往上贴并且尽量靠左;  求每个广告的所在的位置,不能贴则为-1. 用线段树模拟,要是左子树的最大值比当前广告大,就查询更新左子树,否则就右子树. #include <iostream> #include <cstdio> #include <cstrin…
<题目链接> 题目大意: 有一块h*w的矩形广告板,要往上面贴广告,然后给n个1*wi的广告,要求把广告贴上去,而且要求广告要尽量往上贴并且尽量靠左, 求第n个广告的所在的位置,不能贴则为-1. 解题分析: 先抛开本题的数据范围不谈,本题的思路就变的十分简单,无非就是每输入一个纸条的长度,判断一下该广告牌上剩余长度最大的层的剩余长度是否大于该纸条长度,若大于,则该层剩余长度要减去这个纸条的长度,若小于,则输出-1. 但很不幸,本题的数据范围十分之大,如果直接暴力查找剩余长度最大的层,毫无疑问会…
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…
题目大意:有一个h*w的公告榜,可以依次在上面添加信息.每个信息的长度为x,高为1. 优先在最上面加入,如果空间足够的话,然后优先放在最左面.统计每条公告最终的位置,即它所在的行数. 这里是线段树来存储 当前区间(i,j)的所有位置,剩余的最大空间. 初始化即为w,公告榜的宽. Problem Description At the entrance to the university, there is a huge rectangular billboard of size h*w (h is…
Billboard Time Limit: 20000/8000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem 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…
Billboard Time Limit: 20000/8000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 15625    Accepted Submission(s): 6580 Problem Description At the entrance to the university, there is a huge rectangular billboard of…
Billboard Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2795 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…
Description 在学校的入口处有一个巨大的矩形广告牌,高为h,宽为w.所有种类的广告都可以贴,比如ACM的广告啊,还有餐厅新出了哪些好吃的,等等..   在9月1号这天,广告牌是空的,之后广告会被一条一条的依次贴上去.   每张广告都是高度为1宽度为wi的细长的矩形纸条.   贴广告的人总是会优先选择最上面的位置来帖,而且在所有最上面的可能位置中,他会选择最左面的位置,而且不能把已经贴好的广告盖住. 如果没有合适的位置了,那么这张广告就不会被贴了.   现在已知广告牌的尺寸和每张广告的尺…
Summer WarsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88994#problem/J Description The mafia is finally resting after a year of hard work and not so much money. Mafianca, the little mascot of the…
Billboard Time Limit: 20000/8000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 14337    Accepted Submission(s): 6148 Problem Description At the entrance to the university, there is a huge rectangular billboard of…
题目链接: 传送门 Billboard Time Limit: 2000MS     Memory Limit: 32768 K Description At the entrance to the university, there is a huge rectangular billboard of size hw (h is its height and w is its width). The board is the place where all possible announcem…
题目大意:在h*w 高乘宽这样大小的 board上要贴广告,每个广告的高均为1,wi值就是数据另给,每组数组给了一个board和多个广告,要你求出,每个广告应该贴在board的哪一行,如果实在贴不上,就输出-1: 这个题目也难以想到居然是用线段树来做 我们需要考虑的是,线段树究竟表示的是什么数据.在这个题目里,由于每个广告的高都为1,是不是好像感觉每一行都是一个叶子节点一样.没错,就是这样...化抽象为具体一点,那就是把这个board给竖起来,这样最底部的孩子存贮了当前行的空闲宽度,每个父节点都…
给出一个高为h,宽为w的广告板,有n张广告需要贴,从第一行开始贴,尽量靠左,输出每个广告最后贴在哪一行的 先一直想不通这样建树是为什么 后来看到一篇题解里面的一句话“直到找到一个满足条件的叶子节点” 所以用min(h,n)建树,最后输出的为哪一行,即为一个单点(线段树的最末一层) 大概像这样 然后就是更新值,查询 #include <cstdio> #include <ctime> #include <cstring> #include <cstdlib>…
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1036 题意:略. 题解:树链剖分模版,注意一些细节即可. #include <iostream> #include <cstring> #include <cstdio> using namespace std; const int M = 3e4 + 10; struct Edge { int v , next; }edge[M << 1]; in…
题意: h*w的白板. 有n个广告牌,每个广告牌是1*wi.必须放置在白板的upmost中的leftmost. 输出n个广告牌放置在第几行.如果放不下,输出-1. 数据规格: h, w, and n (1 <= h,w <= 10^9; 1 <= n <= 200,000) 思路: 每行最少放一个,所以最多需要n行. 这道题要早最靠左的放得下广告牌的行号.线段树,, 代码: const int maxn = 200005; int maxs[maxn<<2]; int…
注意h的范围和n的范围,纵向建立线段树 题意:h*w的木板,放进一些1*L的物品,求每次放空间能容纳且最上边的位子思路:每次找到最大值的位子,然后减去L线段树功能:query:区间求最大值的位子(直接把update的操作在query里做了)3 5 524333 1213-1 2015-05-15 #include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include…
题意:有个公告板,大小为h*w,要贴n张公告,每个公告的长度是x,高度固定为1,公告放的要尽可能靠上并尽可能靠左,每给出一张公告,要求这个公告在满足要求的情况下放在了第几层. Sample Input3 5 524333 Sample Output1213-1 # include <iostream> # include <cstdio> # include <cstring> # include <algorithm> # include <cmat…
题目传送门 /* 主要利用线段树求区间最值,sum[]代表位置可用空间 每次找到最大值的位置 功能:查询最靠前能容纳广告的位置 */ #include <cstdio> #include <cstring> #include <algorithm> #define lson l, m, rt << 1 #define rson m+1, r, rt << 1 | 1 + ; int w[MAX_N]; int num[MAX_N]; ]; int…