如何建站,知识付费问答系统网站开发,男做直播网站,如何注册域名?成本多少题意#xff1a; 给出一块h*w的广告牌#xff0c;还有n张1*u的海报#xff0c;海报尽量往上#xff0c;左边的位置张贴#xff0c;问每一张海报能贴的多高。 线段树单点修改。 注意#xff1a;因为1 h,w 10^9; 1 n 200,000#xff0c;但实际上…题意 给出一块h*w的广告牌还有n张1*u的海报海报尽量往上左边的位置张贴问每一张海报能贴的多高。 线段树单点修改。 注意因为1 h,w 10^9; 1 n 200,000但实际上若hn的话最坏的情况下也只要用到前n行。 所以若hn 则hn 如果不加这一句因为线段树的数组要开到h2这么大又h 10^9所以输入的h过大时会使开的数组过大。加了的话就不会啦n2是OK的。 1 #includecstdio2 #includealgorithm3 using namespace std;4 #define lson l,m,rt15 #define rson m1,r,rt1|16 const int maxh200010;7 int _max[maxh2];8 int ans;9 void pushup(int rt)
10 {
11 _max[rt]max(_max[rt1],_max[rt1|1]);
12 }
13 void query(int u,int l,int r,int rt)
14 {
15 if(lr){
16 _max[rt]-u;
17 ansl;
18 return ;
19 }
20 int m(lr)1;
21 if(_max[rt1]u)
22 query(u,lson);
23 else
24 query(u,rson);
25 pushup(rt);
26 }
27 int main()
28 {
29 int h,w,n;
30 while(scanf(%d%d%d,h,w,n)!EOF){
31 if(hn)
32 hn;
33 for(int i1;i(h2);i)
34 _max[i]w;
35 int u;
36 for(int i0;in;i){
37 scanf(%d,u);
38 if(_max[1]u)
39 printf(-1\n);
40 else{
41 query(u,1,h,1);
42 printf(%d\n,ans);
43 }
44 }
45 }
46 return 0;
47 } View Code 转载于:https://www.cnblogs.com/-maybe/p/4355771.html