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

asp 做网站的缺点镇江关键字优化品牌

asp 做网站的缺点,镇江关键字优化品牌,网页源代码里哪个是视频链接,学平面设计在哪里学对顶堆的作用主要在于动态维护第k大的数字#xff0c;考虑使用两个优先队列#xff0c;一个大9999999999根堆一个小根堆#xff0c;小根堆维护大于等于第k大的数字的数#xff0c;它的堆顶就是堆内最小#xff0c;第k大的数字#xff0c;另外一个大根堆维护小于等于k的数…对顶堆的作用主要在于动态维护第k大的数字考虑使用两个优先队列一个大9999999999根堆一个小根堆小根堆维护大于等于第k大的数字的数它的堆顶就是堆内最小第k大的数字另外一个大根堆维护小于等于k的数字堆顶是最大的如此一来就可以以排序的方式进行数字交换了 1.板子题 P7072 [CSP-J2020] 直播获奖 // Problem: // P7072 [CSP-J2020] 直播获奖 // // Contest: Luogu // URL: https://www.luogu.com.cn/problem/P7072 // Memory Limit: 256 MB // Time Limit: 1000 ms // // Powered by CP Editor (https://cpeditor.org)#includeiostream #includequeue #includecstring #includealgorithm using namespace std;int main(){int n,m;cinnm;priority_queueint a;//大根堆priority_queueint,vectorint,greaterint b;for(int i1;in;i){int x;cinx;if(b.empty()||xb.top()) b.push(x);else a.push(x);int kmax(1,i*m/100);if(b.size()k) a.push(b.top()),b.pop();if(b.size()k) b.push(a.top()),a.pop();coutb.top() ;}return 0; } 2.中位数 不知道为啥开绿题可能是没标签我就想不到用对顶堆 代码如下 // Problem: // P1168 中位数 // // Contest: Luogu // URL: https://www.luogu.com.cn/problem/P1168 // Memory Limit: 128 MB // Time Limit: 1000 ms // // Powered by CP Editor (https://cpeditor.org)#includeiostream #includequeue using namespace std;int main(){int n;cinn;priority_queueint a;priority_queueint,vectorint,greaterint b;for(int i1;in;i){int x;cinx;if(b.empty()||xb.top()) b.push(x);else a.push(x);if(i%2){int k(i1)/2;while(b.size()k) b.push(a.top()),a.pop();while(b.size()k) a.push(b.top()),b.pop();coutb.top()endl;}}return 0; } 3.P1801 黑匣子 这道题反其行之维护的是第k小实际上是一样的我们稍微想想就能发现第k小的数字不就是大根堆的堆顶吗稍微改一下代码就行。 这道题让我找到了对顶堆的局限性动态查第k个数字变化不能很大否则就会TLE限定 // Problem: // P1801 黑匣子 // // Contest: Luogu // URL: https://www.luogu.com.cn/problem/P1801 // Memory Limit: 500 MB // Time Limit: 500 ms // // Powered by CP Editor (https://cpeditor.org)#includeiostream #includequeue #includevector using namespace std;int main(){int n,m;cinnm;vectorint a(n2);vectorint b(m2);for(int i1;in;i) cina[i];for(int i1;im;i) cinb[i];b[m1]1e9;priority_queueint c;priority_queueint,vectorint,greaterint d;int cnt1,k0;for(int i1;in;i){if(c.empty()||a[i]c.top()) c.push(a[i]);else d.push(a[i]);while(b[cnt]i){k;cnt;while(c.size()k) d.push(c.top()),c.pop();while(c.size()k) c.push(d.top()),d.pop();coutc.top()endl;} } } 4.P2085 最小函数值 原本想了想用偏暴力的方法AC了结果发现原来是数据不好 我的想法是到了一定大小x方就会作为主力 原代码如下用n1 m10000就可以hack掉 // Problem: // P2085 最小函数值 // // Contest: Luogu // URL: https://www.luogu.com.cn/problem/P2085 // Memory Limit: 125 MB // Time Limit: 1000 ms // // Powered by CP Editor (https://cpeditor.org)#includeiostream #includealgorithm #includequeue using namespace std; const int N1e410;int main(){priority_queueint a;priority_queueint,vectorint,greaterint b;int n,m;cinnm;for(int i1;in;i){int x,y,z;cinxyz;for(int j1;j500;j){int kx*j*jy*jz;if(a.empty()||ka.top()) a.push(k);else b.push(k);}}while(a.size()m) b.push(a.top()),a.pop();while(a.size()m) a.push(b.top()),b.pop();vectorint c((int)a.size()1);int lena.size();for(int i1;ilen;i){c[i]a.top();a.pop();}for(int ilen;i1;--i){coutc[i] ;}coutendl;return 0; } 这里有一种优化的方法也就是加入了一个break在一定次数后操作次数就会变得很少就会导致break掉。这里其实无需维护那个小根堆直接维护大根堆即可因为小根堆的作用是处理那个变化的m这里的m是不变的 // Problem: // P2085 最小函数值 // // Contest: Luogu // URL: https://www.luogu.com.cn/problem/P2085 // Memory Limit: 125 MB // Time Limit: 1000 ms // // Powered by CP Editor (https://cpeditor.org)#includeiostream #includealgorithm #includequeue using namespace std; const int N1e410;int main(){priority_queueint a;int n,m;cinnm;for(int i1;in;i){int x,y,z;cinxyz;for(int j1;jm;j){int kx*j*jy*jz;if(a.size()m) a.push(k);else{if(a.top()k) a.push(k),a.pop();else break;}}}//while(a.size()m) b.push(a.top()),a.pop();//while(a.size()m) a.push(b.top()),b.pop();vectorint c((int)a.size()1);int lena.size();for(int i1;ilen;i){c[i]a.top();a.pop();}for(int ilen;i1;--i){coutc[i] ;}coutendl;return 0; }
http://www.w-s-a.com/news/792868/

相关文章:

  • 好的宝安网站建设中企动力的网站开发语言
  • flash网站模板怎么用怎么套模板 网站
  • 建设二手商品网站总结石景山安保服务公司电话
  • 网站建设对于企业的重要性龙岗企业网站设计公司
  • 网站搭建在线支付数码产品网站模板
  • 白云网站建设多少钱WORDPRESS添加前台会员注册
  • 商业网站模板中国字体设计网站
  • 做网站闵行网站建设中英语
  • 写作网站大全如何简单制作生理盐水
  • 云南网站建设维护互联网广告是做什么的
  • 网站 谁建设 谁负责做网站项目
  • 网站建设子栏目怎么弄海口专门做网站
  • 网站建设 温州建设网上银行个人网上银行登
  • 黄页网站推广方案wordpress 压缩插件
  • 网站建设常州网站简介 title
  • 惠州市网站建设个人深圳网站优化价格
  • 营销型网站工程专业网站开发公司
  • 两个路由器做双网站西安关键词优化服务
  • 企业建站系统信息远象建设 网站
  • 移动建站平台物业管理系统app
  • 济南网站建设多少钱郑州公司做网站
  • 在阿里云网站建设wordpress模板如何修改字体
  • 网站推广方案设计购物网站模块例子
  • 潍坊网站定制公司网站图片放大特效怎么做的
  • 淘宝店铺买卖湘潭seo优化价格
  • 最好的网站建设用途合肥企业网站建设
  • 计算机编程与网站建设好玩的网页传奇
  • 商务网站建设找哪家本地推广找哪些网站
  • 手机h5网站企业网站管理系统的运维服务
  • 南京建设网站公司网站游戏怎么制作