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

珠海网站制作报价建设外贸网站案例

珠海网站制作报价,建设外贸网站案例,网站浏览记录怎么做,店铺装修模板【题目来源】 https://www.acwing.com/problem/content/5963/ 【题目描述】 给定一个长度为 n 的数组 a1,a2,…,an,统计前 k 大的数并且把这 k 个数从大到小输出。 【输入格式】 第一行包含整数 n。 第二行包含 n 个整数 a1,a2,…,an。 第三行包含整数 k。​​​​…

【题目来源】
https://www.acwing.com/problem/content/5963/

【题目描述】
给定一个长度为 n 的数组 a1,a2,…,an,统计前 k 大的数并且把这 k 个数从大到小输出。

【输入格式】
第一行包含整数 n。
第二行包含 n 个整数 a1,a2,…,an。
第三行包含整数 k。​​​​​​​

【输出格式】
从大到小输出前 k 大的数,每个数一行。

【数据范围】
1≤n≤10^5,
−10^9≤ai≤10^9,
1≤k≤n

【输入样例】
10
4 5 6 9 8 7 1 2 3 0
5​​​​​​​

【输出样例】
9
8
7
6
5

【算法分析】
● 
vector<int> arr(n); 是创建了一个包含n个int元素的vector,每个元素会被默认初始化为0。

【算法代码】

#include <bits/stdc++.h>
using namespace std;priority_queue<int, vector<int>, greater<int>> L; //小根堆
priority_queue<int> G; //大根堆int main() {int n,k;cin>>n;vector<int> arr(n);for(int i=0; i<n; i++) {cin>>arr[i];}cin>>k;for(int x:arr) {if(L.size()<k) L.push(x);else if(x>L.top()) {L.pop();L.push(x);}}while(!L.empty()) {G.push(L.top());L.pop();}while(!G.empty()) {cout<<G.top()<<endl;G.pop();}return 0;
}/*
in:
10
4 5 6 9 8 7 1 2 3 0
5out:
9
8
7
6
5
*/



【参考文献】
https://blog.csdn.net/hnjzsyjyj/article/details/119813940
https://blog.csdn.net/hnjzsyjyj/article/details/146315528
https://www.acwing.com/solution/content/258025/




 


文章转载自:

http://ByCgF55x.sgnxL.cn
http://UJqeuAe9.sgnxL.cn
http://iZ5v7pKW.sgnxL.cn
http://VkaywFPA.sgnxL.cn
http://Fp3tMbEo.sgnxL.cn
http://feQAGwbc.sgnxL.cn
http://ZTpMJhy3.sgnxL.cn
http://6tx7DLBT.sgnxL.cn
http://YEtQC4N8.sgnxL.cn
http://dy7zD88N.sgnxL.cn
http://ptF3XKjB.sgnxL.cn
http://6hzMMQCZ.sgnxL.cn
http://dIpL3kpS.sgnxL.cn
http://8swaqqJZ.sgnxL.cn
http://zHNiAMXV.sgnxL.cn
http://AWrOskdx.sgnxL.cn
http://1RYjE7lv.sgnxL.cn
http://6A0zL1SO.sgnxL.cn
http://ZoYoaJuC.sgnxL.cn
http://wmRw7RIA.sgnxL.cn
http://0euDfxbx.sgnxL.cn
http://Td7F2xFI.sgnxL.cn
http://1rbhiCk8.sgnxL.cn
http://8mU439TD.sgnxL.cn
http://KKYQiovQ.sgnxL.cn
http://WpRkvtA2.sgnxL.cn
http://3W8BevbU.sgnxL.cn
http://q4uc59Yb.sgnxL.cn
http://J5e483Ik.sgnxL.cn
http://lqQksXD4.sgnxL.cn
http://www.dtcms.com/wzjs/657858.html

相关文章:

  • 网站建设竞价托管服务网易企业邮箱服务器配置
  • 用dw设计网站模板下载介绍自己公司的范文
  • 生态农业网站建设方案肇庆网站快速排名优化
  • 做教育集团的网站建设微信开放平台介绍
  • 如何添加百度指数网站开发和优化关系
  • 深圳网站建设深圳网站目录结构怎么做
  • 南通做网站多少钱网站建设的要求及标准
  • 常用的cms建站系统如何做好网络营销工作
  • 如何自己做收费的视频网站免费软件下载网站
  • 邵阳建设网站公司做网站效果图
  • 沈阳软件公司 网站制作舞美设计制作公司
  • 深圳云网站建站公司商务局网站建设
  • 学生做网站的软件网址大全浏览器下载
  • 网站分类目录查询中国最大网站建设公司
  • 电子商务网站建设与管理实训总结手机网站漂浮怎么做
  • 深圳搜豹网站建设公司推广公司怎么找
  • 花店网站源码汉中中药材初加工平台
  • 做网站的程序员厦门关键词seo排名网站
  • 网站做水印有没有影响吗软件定制开发公司排名
  • 做网站最好的软件ps制作网站模板
  • 做网站需要每年都缴费吗wordpress用户修改邮箱
  • 网站建设服务商城整站优化和单词
  • 中医网站模板做携程网站的技术
  • 网站后台上传图片不显示淘宝店铺首页装修
  • 佛山建设局官方网站龙岗网红公园
  • 购物网站主页设计图中国网重庆频道
  • 做网站和微信公众号如何招生免费资源部落wordpress
  • 单位网站建设典型材料免费ai写作网站3000字
  • 企业宣传网站建设用jsp做网站步骤
  • 档案网站建设与知识管理好的文案网站