当前位置:网站首页>[Acwing]第 60 场周赛 B- 4495. 数组操作
[Acwing]第 60 场周赛 B- 4495. 数组操作
2022-07-17 12:39:00 【*DDL_GzmBlog】
前言
t a g : tag : tag:模拟STL排序
传送门 :
这题10分钟才出货,题目看了好几遍,今天昏头了属于是
思路 :
我们只需要 排序,排序!,之后直接模拟即可
我们需要实时计算需要减的值
然后每次减的时候,及时的踢出已经减为 0 0 0的值
code :
ll n,k;
vector<ll> v;
int i,j;
void solve(){
cin>>n>>k;
Fup(i,1,n){
//for(int i=1;i<=n;i++) 等同于
int x;cin>>x;
if(!x)continue;
v.pb(x);
}
sort(all(v),greater<int>());
int d = 0 ;
//计算需要减去的差值
while(k -- ){
if(v.size() == 0){
cout<<0<<endl;
continue;
}
if(v.back() - d !=0){
cout<<v.back()-d<<endl;
d+=(v.back()-d);
//可能有多个相同所以需要while
while(v.back() -d == 0)
v.pop_back();
}else cout<<0<<endl;
}
}
边栏推荐
- 架构实战营|模块7
- 王者荣耀商城异地多活架构设计
- AutoJs学习-多功能宝箱-中
- 024.static与final使用陷阱 续
- 【Makefile】关于makefile使用上的一些备忘
- R language ggplot2 visualization: use the gghistogram function of ggpubr package to visualize the grouping histogram, and use the palette parameter to customize the bar border color of the grouping hi
- STM32F407 NVIC
- 华为防火墙(NGFW)的双机热备
- 【PostgreSQL 】PostgreSQL 15对distinct的优化
- R语言使用R原生函数进行数据聚合统计(Aggregating transforms)计算滑动窗口统计值(Window Statistics)、计算滑动分组最小值(min)并合并生成的统计数据到原数据集
猜你喜欢

string类的介绍及模拟实现

爱可可AI前沿推介(7.17)

Stream流

华为防火墙(NGFW)的双机热备

Bidirectional NAT Technology

知其然,而知其所以然,JS 对象创建与继承

因果学习将开启下一代AI浪潮?九章云极DataCanvas正式发布YLearn因果学习开源项目

Virtual CPU and memory in yarn (CDH)

opencv 画黑色矩形,并写上序号

2022 Hunan secondary vocational group "Cyberspace Security" packet analysis infiltration Pacpng parsing (super detailed)
随机推荐
R语言ggplot2可视化:使用ggpubr包的gghistogram函数可视化分组直方图、使用palette参数自定义分组直方图的条形边框颜色
华为机试:报文解压缩
FreeRTOS个人笔记-临界值的保护
HCIA static comprehensive experiment report 7.10
SAP ABAP CDS view 视图的 Replacement 技术介绍
因果学习将开启下一代AI浪潮?九章云极DataCanvas正式发布YLearn因果学习开源项目
智能存储柜控制系统设计及仿真
AutoJs学习-多功能宝箱-中
R language uses LM function to build linear regression model, and uses subset function to specify the subset of data set to build regression model (uses subset function to filter the data subset that
【Unity技术积累】实现鼠标画线功能 & LineRenderer
树的基本操作
Domestic flagship mobile phones have a serious price foam, and second-hand phones are more cost-effective than new ones, or buy iPhones
二叉树的概念及三种遍历方法(C语言)
The use and Simulation of stack and queue in STL
HCIA 复习作答 2022.7.6
AutoJs学习-动态解密
The R language uses the plot function in the native package (basic import package, graphics) to visualize the scatter plot
R language uses the ordinal of epidisplay package or. The display function obtains the summary statistical information of the ordered logistic regression model (the odds ratio and its confidence inter
Distinction between private key and public key -- Explanation of private key and public key
Through middle order traversal and pre order traversal, the subsequent traversal will always build a binary tree