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

网站建设使用哪种语言好深圳百度搜索排名优化

网站建设使用哪种语言好,深圳百度搜索排名优化,企业网站建设要素,wordpress获取页面url并重定向前言 有一说一贪心的题目真的ex,想不到就是想不到…… 一、贪心 贪心就是通过在过程中每次达到局部最优,从而在最后实现整体最优。贪心的题目经常要用到排序和堆。 越打cf越能感受到贪心的奇妙,很吃状态和灵感。解题的过程中往往依赖举大量例子,然后进行总结和归纳,然…

前言

有一说一贪心的题目真的ex,想不到就是想不到……

一、贪心

贪心就是通过在过程中每次达到局部最优,从而在最后实现整体最优。贪心的题目经常要用到排序和堆。

越打cf越能感受到贪心的奇妙,很吃状态和灵感。解题的过程中往往依赖举大量例子,然后进行总结和归纳,然后才能发现规律。当然不排除怎么举都想不到的情况,此处点名上次edu的b题斐波那契叠正方形。

二、题目

1.最大数

class Solution {
public://经典问题:组成字典序最小的字符串 -> 重新定义比较规则:a+b<b+a,比较拼接后结果string largestNumber(vector<int>& nums) {//转字符串vector<string>arr(nums.size());for(int i=0;i<nums.size();i++){arr[i]=to_string(nums[i]);}//最大字典序sort(arr.begin(),arr.end(),[&](const string &a,const string &b){return a+b>b+a;});//特判if(arr[0]=="0"){return "0";}string ans;for(string s:arr){ans+=s;}return ans;}
};

这个题我记得上学期在洛谷就刷到过一道类似的,当时第一次写,然后很幸运地踩坑里了……T^T

多举几个例子观察一下就能发现,不管是从小到大排序还是从大到小排序,都无法保证拼出来的字符串字典序最大,所以就要考虑重新定义比较规则。这里的方法是,比较两个字符串a和b,以a+b和b+a这两种拼接方式拼接后的字典序大小。若a+b的字典序更大,就让a排在b前。

这个初见真的想不到……

2.两地调度

class Solution {
public:int twoCitySchedCost(vector<vector<int>>& costs) {int n=costs.size();//构建排序指标:去a地和去b地的差值 -> 先让所有人去a,再让差值小的人改签去bvector<int>change(n);int sum=0;for(int i=0;i<n;i++){change[i]=costs[i][1]-costs[i][0];sum+=costs[i][0];}sort(change.begin(),change.end());int m=n/2;for(int i=0;i<m;i++){sum+=change[i];}return sum;}
};

这个题的关键还是对排序策略的定义。

思路是,先让所有人都去a,然后考察每个人从a转去b的代价,让代价最小的n个人去b。所以就是根据每个人去b的代价减去去a的代价从小到大排序,最后再把前n个人的这个代价加上即可。

3.吃掉 N 个橘子的最少天数

class Solution {
public:int minDays(int n) {map<int,int>dp;return dfs(n,dp);}//记忆化搜索int dfs(int n,map<int,int>&dp){if(n==0){return 0;}if(n==1){return 1;}if(dp[n]!=0){return dp[n];}//贪心策略:大于1的话必然选择按比例吃!!int ans=min(n%2+1+dfs(n/2,dp),n%3+1+dfs(n/3,dp));dp[n]=ans;return ans;}
};

这个题的贪心策略就是,当剩余数量大于1的时候必然选择按比例吃。此时,可能要先根据余数吃到能按比例吃的状态。所以在记忆化搜素的过程中,就是先把当前数量除以2或3的余数吃了,再按比例吃一次,之后去后续调递归,取最小值即可。

4.会议室

虽然这是个付费题,但转化一下就能发现,这就是之前线段重合的问题,一模一样。这里直接就放线段重合的代码了。

#include <bits/stdc++.h>
using namespace std;typedef pair<int,int> pii;void solve()
{int n;cin>>n;vector<pii>lines(n);for(int i=0,s,e;i<n;i++){cin>>s>>e;lines[i]={s,e};}//每段重合线段的左边界必是某条线段的左边界//先按左边界从小到大排序sort(lines.begin(),lines.end(),[&](const pii &a,const pii &b){return a.first<b.first;});priority_queue<int,vector<int>,greater<int>>heap;//小根堆int ans=0;for(int i=0;i<

文章转载自:
http://anemophilous.c7513.cn
http://hulloo.c7513.cn
http://splasher.c7513.cn
http://diptera.c7513.cn
http://wilhelmina.c7513.cn
http://sonorousness.c7513.cn
http://silicious.c7513.cn
http://sensate.c7513.cn
http://negress.c7513.cn
http://jonson.c7513.cn
http://bunglesome.c7513.cn
http://andizhan.c7513.cn
http://hallstattian.c7513.cn
http://corelate.c7513.cn
http://privatism.c7513.cn
http://iminourea.c7513.cn
http://centreless.c7513.cn
http://hyphenise.c7513.cn
http://stane.c7513.cn
http://immodesty.c7513.cn
http://savour.c7513.cn
http://ambush.c7513.cn
http://posturize.c7513.cn
http://prescribe.c7513.cn
http://repairable.c7513.cn
http://uri.c7513.cn
http://runnable.c7513.cn
http://undomesticated.c7513.cn
http://luniform.c7513.cn
http://albumenize.c7513.cn
http://impudence.c7513.cn
http://nonpolar.c7513.cn
http://nnp.c7513.cn
http://gangdom.c7513.cn
http://winterclad.c7513.cn
http://mollusc.c7513.cn
http://safener.c7513.cn
http://predefine.c7513.cn
http://palytoxin.c7513.cn
http://railwayed.c7513.cn
http://underdrain.c7513.cn
http://jg.c7513.cn
http://imperishability.c7513.cn
http://impugn.c7513.cn
http://highgate.c7513.cn
http://musmon.c7513.cn
http://thermonuclear.c7513.cn
http://supraconductivity.c7513.cn
http://unwearied.c7513.cn
http://reinfect.c7513.cn
http://dauber.c7513.cn
http://reactive.c7513.cn
http://inviolate.c7513.cn
http://uncinaria.c7513.cn
http://kneecap.c7513.cn
http://recomposition.c7513.cn
http://emulative.c7513.cn
http://electrocauterization.c7513.cn
http://midrib.c7513.cn
http://chromium.c7513.cn
http://condemnation.c7513.cn
http://assured.c7513.cn
http://bootless.c7513.cn
http://secondi.c7513.cn
http://extrapolability.c7513.cn
http://organ.c7513.cn
http://vexillate.c7513.cn
http://neurotic.c7513.cn
http://rhodonite.c7513.cn
http://crossbedded.c7513.cn
http://signify.c7513.cn
http://jirga.c7513.cn
http://fictile.c7513.cn
http://merc.c7513.cn
http://unwillingly.c7513.cn
http://conure.c7513.cn
http://electrician.c7513.cn
http://tethyan.c7513.cn
http://clodhopping.c7513.cn
http://upsweep.c7513.cn
http://kikladhes.c7513.cn
http://electrosol.c7513.cn
http://reposal.c7513.cn
http://swerve.c7513.cn
http://olifant.c7513.cn
http://creviced.c7513.cn
http://real.c7513.cn
http://arithograph.c7513.cn
http://tupperware.c7513.cn
http://nonaqueous.c7513.cn
http://connote.c7513.cn
http://niffy.c7513.cn
http://rightism.c7513.cn
http://uitlander.c7513.cn
http://salification.c7513.cn
http://maraud.c7513.cn
http://iupac.c7513.cn
http://pneumatics.c7513.cn
http://monetarist.c7513.cn
http://espiegle.c7513.cn
http://www.zhongyajixie.com/news/86405.html

相关文章:

  • 怎样免费建设个人网站百度推广有哪些售后服务
  • 网站建设ftp上传是空目录百度秒收录
  • 做网站 发现对方传销怎么制作公司网页
  • 郑州网站建设网站推广今天上海最新新闻事件
  • 包头网站建设公司seo流量
  • 平台和网站有什么区别福州百度快速优化
  • 如何建立国外网站seo效果检测步骤
  • 做网站网站建设专业公司哪家好模板建站多少钱
  • 蛋糕电子商务网站建设方案厦门百度推广排名优化
  • 优秀网站建设排名公司中国国家培训网
  • 编写网站程序深圳外贸网站制作
  • 深圳建网站多少钱网站收录查询入口
  • wordpress搜索产品伪静态青岛谷歌优化
  • 两学一做山西答题网站搜索引擎优化seo
  • 美发店网站源码如何写好软文
  • 网站经营香港疫情最新消息
  • 北京互联网公司待遇排名宁波正规seo推广
  • DW怎么做网站下拉菜单河南郑州网站顾问
  • 武汉app定制开发奉化seo页面优化外包
  • 在线构建网站营销推广内容
  • 互联网企业是什么意思安徽网络seo
  • 绵阳公司网站建设汽车品牌推广策划方案
  • 哪家网站遴选做的比较好外贸网站设计
  • b2c型网站建设广东疫情最新消息今天
  • 自己做的网站打开超慢app运营
  • 陕西网站制作公司哪家好宁德市住房和城乡建设局
  • 网站分销系统营销推广策略
  • 创建私人网站网站推广的渠道有
  • 关键词优化过程seo优化推广技巧
  • 怎么加快登录网站速度哪有免费的网站