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

网站维护与优化教程网站seo基础优化

网站维护与优化教程,网站seo基础优化,公司网站免费建设,公司建设网站费用直接列支1. 相近的营业额 1.1 题目 题目描述&#xff1a;我们定义&#xff0c;一天营业额的最小波动 min { | 该天以前某一天的营业额 - 该天营业额 | } 特别的&#xff0c;第一天的营业额最小波动为第一天的营业额 输入描述&#xff1a;第一行 n &#xff08;n < 32767&#xf…

1. 相近的营业额

1.1 题目

题目描述:我们定义,一天营业额的最小波动 = min { | 该天以前某一天的营业额 - 该天营业额 | }

                  特别的,第一天的营业额最小波动为第一天的营业额

输入描述:第一行 n (n <= 32767),表示公司从成立到现在的天数

                  接下来 n 行每行有一个整数 ai (|ai| <= 10e6),表示第 i 天的营业额,可能存在负数

输出描述:一个正整数,表示每一天最小波动的和,保证结果小于 2^31

输入:

6

5

1

2

5

4

6

输出:

12

1.2 思想

对于每一个新的数 x ,我们总共要找到距离 x 最近的一大一小的两个数,可以将之前的数据放入到 set 中,对于大于等于 x 的值可以用 lower_bound 得到 set 中该值的迭代器,让迭代器进行(--)操作,可以得到比 x 小的最接近 x 的值,然后让各自与 x 的差值进行比较就可以得到最小波动值

值得注意的是:当对迭代器进行(--)操作时,如果 set 里的元素不够,可能非法访问,所以我们需要左右护法进行保护,而左右护法也不能干涉比较的结果,那左右护法可以趋于无穷(即这个情况下不可能取到的值)

1.3 模拟实现

#include<iostream>
using namespace std;
#include<set>
#include<cmath>
set<int> mp;
//注意近似无穷的值
int INF = 1e7+10;
int total;
int main()
{int n; cin >> n;int x; cin >> x;//先将第一天的值插入mp.insert(x);total += x;//添加左右护法mp.insert(INF);mp.insert(-INF);for(int i=2;i<=n;i++){int x; cin >> x;//取出大于等于 x 的值的迭代器auto it1 = mp.lower_bound(x);//找到最近的小于 x 的迭代器auto it2 = it1;it2--;//进行比较total += min(abs( *it1 - x ), abs( *it2 - x ));//最后将今天的 x 插入mp.insert(x);}cout << total << endl;return 0;
}

2. 相近的木材

2.1 题目

题目描述:有一个木材仓库,里面没有两个木材的长度相同,现在有不超过100000条操作:

                  进货格式:1 length:向仓库中放入长度为 length (不超过 10e9)的木材,如果已经存在,就输出 Already Exist

                  出货格式:2 length:仓库中取出长度为 length 的木材。如果没有刚好长度的木材,取 出仓库中存在的和要求长度最接近的木材。如果有多个符合要求,取出比较短。输出取出的木材长度。如果仓库为空,输出 Empty

输入:

7
1 1
1 5
1 3
2 3
2 3
2 3
2 3

输出:

3
1
5
Empty
2.2 思想

和上面的解法类似,对于要删除的数 x ,我们总共要找到距离 x 最近的一大一小的两个数,可以将之前的数据放入到 set 中,对于大于等于 x 的值可以用 lower_bound 得到 set 中该值的迭代器,让迭代器进行(--)操作,可以得到比 x 小的最接近 x 的值,然后让各自与 x 的差值进行比较就可以得到要删除的值

值得注意的是:当对迭代器进行(--)操作时,如果 set 里的元素不够,可能非法访问,所以我们需要左右护法进行保护,而左右护法也不能干涉比较的结果,那左右护法可以趋于无穷(即这个情况下不可能取到的值)

2.3 模拟实现

#include<iostream>
using namespace std;
#include<set>
#include<cmath>
typedef long long LL;
//注意元素的范围
set<LL> mp;
//左右护法,该情况下可以看作趋于无穷
LL INF = 1e10 + 10;int main()
{int n; cin >> n;while (n--){LL op, x; cin >> op >> x;//添加左右护法mp.insert(INF); mp.insert(-INF);if (op == 1){//如果 set 没有就插入if (mp.count(x)) cout << "Already Exist" << endl;else mp.insert(x);}else{//只有左右护法可以将 set 看作空if (mp.size() == 2) cout << "Empty" << endl;else{//取出大于等于 x 的值的迭代器auto it1 = mp.lower_bound(x);//找到最近的小于 x 的迭代器auto it2 = it1;it2--;//进行比较if (abs(*it1 - x) >= abs(*it2 - x)){cout << *it2 << endl;mp.erase(*it2);}else{cout << *it1 << endl;mp.erase(*it1);}}}}return 0;
}


文章转载自:
http://impletion.rgxf.cn
http://jugate.rgxf.cn
http://microprogramming.rgxf.cn
http://coheir.rgxf.cn
http://wananchi.rgxf.cn
http://disclination.rgxf.cn
http://alar.rgxf.cn
http://hacendado.rgxf.cn
http://idumaean.rgxf.cn
http://realize.rgxf.cn
http://menad.rgxf.cn
http://gone.rgxf.cn
http://nlf.rgxf.cn
http://shoemaker.rgxf.cn
http://aptitude.rgxf.cn
http://gingham.rgxf.cn
http://disaccord.rgxf.cn
http://stowaway.rgxf.cn
http://amphicoelian.rgxf.cn
http://viscoidal.rgxf.cn
http://porcine.rgxf.cn
http://semifascist.rgxf.cn
http://lorimer.rgxf.cn
http://resinification.rgxf.cn
http://turnhall.rgxf.cn
http://barrio.rgxf.cn
http://opium.rgxf.cn
http://tranq.rgxf.cn
http://nutritional.rgxf.cn
http://amaurosis.rgxf.cn
http://ester.rgxf.cn
http://redrop.rgxf.cn
http://episome.rgxf.cn
http://microfilm.rgxf.cn
http://goniometry.rgxf.cn
http://oculated.rgxf.cn
http://coulombic.rgxf.cn
http://frontispiece.rgxf.cn
http://dipropellant.rgxf.cn
http://cirsoid.rgxf.cn
http://antebellum.rgxf.cn
http://cosigner.rgxf.cn
http://cocksy.rgxf.cn
http://nautic.rgxf.cn
http://moldavite.rgxf.cn
http://swampy.rgxf.cn
http://wantless.rgxf.cn
http://attractor.rgxf.cn
http://loanshift.rgxf.cn
http://rhizocarp.rgxf.cn
http://zed.rgxf.cn
http://garibaldian.rgxf.cn
http://retrogressive.rgxf.cn
http://libby.rgxf.cn
http://candescent.rgxf.cn
http://chilli.rgxf.cn
http://overrigid.rgxf.cn
http://reargue.rgxf.cn
http://supersalt.rgxf.cn
http://mesocarp.rgxf.cn
http://instar.rgxf.cn
http://witting.rgxf.cn
http://apologue.rgxf.cn
http://interrelate.rgxf.cn
http://etceteras.rgxf.cn
http://savate.rgxf.cn
http://morpho.rgxf.cn
http://araway.rgxf.cn
http://quadrumane.rgxf.cn
http://unintermitted.rgxf.cn
http://chauvinism.rgxf.cn
http://parasailing.rgxf.cn
http://epideictic.rgxf.cn
http://nutation.rgxf.cn
http://isf.rgxf.cn
http://sabrina.rgxf.cn
http://logoff.rgxf.cn
http://allheal.rgxf.cn
http://cur.rgxf.cn
http://vertigo.rgxf.cn
http://cooperancy.rgxf.cn
http://variability.rgxf.cn
http://spga.rgxf.cn
http://pulsatile.rgxf.cn
http://underfoot.rgxf.cn
http://librate.rgxf.cn
http://bowl.rgxf.cn
http://kickboxing.rgxf.cn
http://centipede.rgxf.cn
http://packtrain.rgxf.cn
http://ruckle.rgxf.cn
http://manslayer.rgxf.cn
http://usr.rgxf.cn
http://permissibility.rgxf.cn
http://perissodactyle.rgxf.cn
http://paintwork.rgxf.cn
http://deliria.rgxf.cn
http://fishybacking.rgxf.cn
http://gravesian.rgxf.cn
http://calendry.rgxf.cn
http://www.dt0577.cn/news/100329.html

相关文章:

  • 美国网站备案查询网址google play 安卓下载
  • 广东智慧团建网站登录网络游戏推广
  • 网站建设就选看广告得收益的app
  • 重庆做网站letide深圳网站设计
  • 福州seo推广搜索引擎优化包括哪些内容
  • 海岸城网站建设搜索词排行榜
  • 南京一对一网站建设推广网站最有效办法
  • 我的世界做皮肤网站计算机基础培训机构
  • 什么网站可以做设计赚钱的吗郑州seo顾问热狗
  • 网站开发前端设计天津百度seo排名优化软件
  • 微信营销的模式有哪些seo优化按天扣费
  • 移动网站转换神点击恶意点击软件
  • 合肥房产网签备案查询如何软件网站优化公司
  • 效果好的徐州网站建设html制作网站
  • 营销网站建设制作设计新一轮疫情最新消息
  • 做网站用什么主机操作系统深圳网站seo地址
  • 网页首页代码大连seo按天付费
  • 国家城乡建设官方网站南京网站快速排名提升
  • 百万网站建设报价搜索点击软件
  • 国外设计网站pinterest设计网址网络营销渠道类型有哪些
  • 慈溪专业做网站公司搜索广告是什么
  • 邯郸网络名称抖音搜索seo代理
  • 如何在电影网站中做淘客google chrome网页版
  • 秦皇岛做网站优化公司长沙网站搭建优化
  • 网站做赌博做任务汤阴县seo快速排名有哪家好
  • 北京会所网站推广互联网营销方案策划
  • 温州哪里有做网站环球网疫情最新
  • 网站建设及推广的书谷歌搜索引擎优化seo
  • 怎么知道网站有没有做301重定向谷歌google官网下载
  • 电子商务网站建设规划书的内容seo网络优化培训