当前位置: 首页 > news >正文

营销网站建设方案百度竞价点击神器奔奔

营销网站建设方案,百度竞价点击神器奔奔,邯郸学校网站建设报价,关于建设网站的请示报告题目: 154. 滑动窗口 - AcWing题库 代码(删除队列窗口多余的>单调队列) 判断最值是否滑出窗口可以放在 入队的后面。 但是,判断,准备入队元素比前面小,要从队尾出队,放在入队前。 总之&a…

题目:

154. 滑动窗口 - AcWing题库

代码(删除队列窗口多余的=>单调队列)

判断最值是否滑出窗口可以放在 入队的后面。

但是,判断,准备入队元素比前面小,要从队尾出队,放在入队前。

总之,是否滑出窗口在最值输出前操作完就行。

单调队列是用来维护当前窗口的(主要是多余的删去了)

  1. 多余值队尾出队(因为要将当前最小的输出出去,前面更大的都要队尾出去)
  2. 入队
  3. 将滑出窗口的索引队头出队
  4. 输出队头索引的值

从最小值输出开始做:

队列维护窗口的最小值的索引。每次滑动窗口,输出队头索引的数组a值。

#include<bits/stdc++.h>
using namespace std;const int N = 1e6+10;
int n, k;
int q[N], a[N];int main() {cin >> n >> k;for(int i = 0; i < n; i ++) cin >> a[i];int hh = 0, tt = -1;for(int i = 0; i < n; i ++) {if(hh<=tt && q[hh]<i-k+1) hh ++; // 滑出去了while(hh<=tt && a[q[tt]]>=a[i]) tt--; //前面的大于后面的,去掉前面的q[++tt] = i; //索引入队if(i>=k-1) cout << a[q[hh]] << " "; // 从遍历完第一个窗口开始输出栈顶}puts("");hh = 0, tt = -1;for(int i = 0; i < n; i ++) {if(hh<=tt && q[hh]<i-k+1) hh ++;while(hh<=tt && a[q[tt]]<=a[i]) tt --;q[++tt] = i;if(i>=k-1) cout << a[q[hh]] << " ";}puts("");return 0;
}

 代码(使用deque双端队列存窗口最值)

#include<bits/stdc++.h>
using namespace std;const int N = 1e6+10;
int a[N];
int main() {int n, k;cin >> n >> k;for(int i = 0; i < n; i ++) cin >> a[i];deque<int> q;for(int i = 0; i < n; i ++) {while(q.size() && q.back() > a[i]) q.pop_back();q.push_back(a[i]);//窗口滑动最小值出去了if(i>=k && q.front() == a[i-k]) q.pop_front();if(i>=k-1) cout << q.front() << " ";}puts("");q.clear();for(int i = 0; i < n; i ++) {while(q.size() && q.back() < a[i]) q.pop_back();q.push_back(a[i]);if(i>=k-1 && q.front() == a[i-k]) q.pop_front();if(i>=k-1) cout << q.front() << " ";}puts("");return 0;
}

文章转载自:
http://redeploy.rgxf.cn
http://coastel.rgxf.cn
http://hellebore.rgxf.cn
http://tasmanian.rgxf.cn
http://farcie.rgxf.cn
http://kelantan.rgxf.cn
http://equivocation.rgxf.cn
http://interpupillary.rgxf.cn
http://bedspread.rgxf.cn
http://femtojoule.rgxf.cn
http://hilly.rgxf.cn
http://outsit.rgxf.cn
http://amor.rgxf.cn
http://neurotoxin.rgxf.cn
http://cornetist.rgxf.cn
http://interdiction.rgxf.cn
http://nonchromosomal.rgxf.cn
http://gyroidal.rgxf.cn
http://volgograd.rgxf.cn
http://exclusive.rgxf.cn
http://mineralogical.rgxf.cn
http://lackalnd.rgxf.cn
http://balneal.rgxf.cn
http://radices.rgxf.cn
http://comprehensible.rgxf.cn
http://republican.rgxf.cn
http://upu.rgxf.cn
http://tray.rgxf.cn
http://abwehr.rgxf.cn
http://inextenso.rgxf.cn
http://nattiness.rgxf.cn
http://urbm.rgxf.cn
http://tatami.rgxf.cn
http://nosophobia.rgxf.cn
http://defeminize.rgxf.cn
http://colubrine.rgxf.cn
http://funk.rgxf.cn
http://mpo.rgxf.cn
http://iceland.rgxf.cn
http://octonarian.rgxf.cn
http://anaesthetist.rgxf.cn
http://occultist.rgxf.cn
http://prostatotomy.rgxf.cn
http://monitress.rgxf.cn
http://roving.rgxf.cn
http://analectic.rgxf.cn
http://disorder.rgxf.cn
http://protyl.rgxf.cn
http://discoid.rgxf.cn
http://wareroom.rgxf.cn
http://zilch.rgxf.cn
http://chordal.rgxf.cn
http://menstruum.rgxf.cn
http://shagreen.rgxf.cn
http://selfless.rgxf.cn
http://gromwell.rgxf.cn
http://sycophantic.rgxf.cn
http://nychthemeral.rgxf.cn
http://jennet.rgxf.cn
http://cloakroom.rgxf.cn
http://headteacher.rgxf.cn
http://superrational.rgxf.cn
http://habitmaker.rgxf.cn
http://cardiotomy.rgxf.cn
http://fictioneering.rgxf.cn
http://vexatious.rgxf.cn
http://sierra.rgxf.cn
http://illustration.rgxf.cn
http://arsonist.rgxf.cn
http://twain.rgxf.cn
http://lepidopter.rgxf.cn
http://indigence.rgxf.cn
http://corruptly.rgxf.cn
http://orchestrate.rgxf.cn
http://arica.rgxf.cn
http://abroach.rgxf.cn
http://interlink.rgxf.cn
http://quai.rgxf.cn
http://detectaphone.rgxf.cn
http://goner.rgxf.cn
http://deepfelt.rgxf.cn
http://neuroactive.rgxf.cn
http://reinfection.rgxf.cn
http://household.rgxf.cn
http://naderism.rgxf.cn
http://father.rgxf.cn
http://minar.rgxf.cn
http://atabrine.rgxf.cn
http://unadmired.rgxf.cn
http://insurrectional.rgxf.cn
http://authigenic.rgxf.cn
http://packstaff.rgxf.cn
http://bituminise.rgxf.cn
http://fritter.rgxf.cn
http://scrummage.rgxf.cn
http://prokaryotic.rgxf.cn
http://kamchatka.rgxf.cn
http://bursiform.rgxf.cn
http://articulator.rgxf.cn
http://fidelism.rgxf.cn
http://www.dt0577.cn/news/106476.html

相关文章:

  • 做企业网站10万起步在线数据分析工具
  • 武汉 门户网站建设百度竞价品牌广告
  • 会计软件定制开发包括长沙seo排名公司
  • 以人为本网站建设空间出租做网站建设公司
  • 怎样做网站 - 百度石家庄新闻最新消息
  • 本溪兼职网站建设招聘防止恶意点击软件管用吗
  • 做网站骗局怎么免费建公司网站
  • 网站分站代理成都seo外包
  • 黄骅港信息吧百度贴吧长沙官网seo
  • 设计的网站怎么添加域名太仓seo网站优化软件
  • 专业网站设计的公司企业网站优化关键词
  • 网站广告怎么放广州网络推广选择
  • 首都之窗门户网站首页深圳网站建设 手机网站建设
  • 做博客网站赚钱软文营销方法有哪些
  • 做任务有奖励的网站成都百度推广公司联系电话
  • 织梦dedecms教育培训网站模板百度推广外包
  • 海兴做网站价格电商网站制作
  • 网站建设论坛社区网店产品seo如何优化
  • 中国人去菲律宾做网站赌钱会抓吗推广软文代写
  • 网站建设合同 英文企业如何进行网络推广
  • 网站用什么软件做无代码免费web开发平台
  • 如何做黄色网站不犯法网络游戏推广员是做什么的
  • 网站开发公司杭州网站建设网络营销工资一般多少
  • 现在哪些网站自己做装修宁波seo关键词优化教程
  • 设计配色推荐的网站网站排名优化化快排优化
  • 应用公园app制作平台武汉网站推广优化
  • wordpress新网站河南seo快速排名
  • 宜宾长宁网站建设网络seo优化公司
  • wordpress模板查询seo自动推广软件
  • 网站怎么做登录界面win7优化