当前位置:网站首页>[acwing] 60th weekly match b- 4495 Array operation
[acwing] 60th weekly match b- 4495 Array operation
2022-07-19 10:41:00 【*DDL_ GzmBlog】
Preface
t a g : tag : tag: simulation STL Sort
Portal :
This question 10 Minutes before shipment , Read the title several times , Dizzy today belongs to
Ideas :
We just need Sort , Sort !, Then directly simulate
We need to calculate the value to be subtracted in real time
Then every time you reduce , The timely kick has been reduced to 0 0 0 Value
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++) Equate to
int x;cin>>x;
if(!x)continue;
v.pb(x);
}
sort(all(v),greater<int>());
int d = 0 ;
// Calculate the difference that needs to be subtracted
while(k -- ){
if(v.size() == 0){
cout<<0<<endl;
continue;
}
if(v.back() - d !=0){
cout<<v.back()-d<<endl;
d+=(v.back()-d);
// There may be multiple identical ones, so you need while
while(v.back() -d == 0)
v.pop_back();
}else cout<<0<<endl;
}
}
边栏推荐
- 因果学习将开启下一代AI浪潮?九章云极DataCanvas正式发布YLearn因果学习开源项目
- Brush questions with binary tree (2)
- Feature level fusion in Bev space
- R language uses the aggregate function of epidisplay package to divide numerical variables into different subsets based on factor variables, calculate the summary statistics of each subset, and set na
- 看一看这丑恶嘴脸 | MathWorks Account Unavailable - Technical Issue
- 欧拉角,轴角,四元数与旋转矩阵详解
- SAP S4 Material Management 库存模块 MARD 数据库表读取技术细节介绍
- SAP Fiori 的附件处理(Attachment handling)
- STM32F407 NVIC
- 2022年全国最新消防设施操作员(中级消防设施操作员)模拟试题及答案
猜你喜欢

C # treeview tree structure recursive processing (enterprise group type hierarchical tree display)

vulnhub inclusiveness: 1

Bidirectional NAT Technology

Pytorch框架 学习记录1 CIFAR-10分类

多元线性回归详解

NJCTF 2017messager

Data Lake solutions of various manufacturers

看一看这丑恶嘴脸 | MathWorks Account Unavailable - Technical Issue

yarn(cdh)中的虚拟cpu和内存

LeetCode 2319. 判断矩阵是否是一个 X 矩阵
随机推荐
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
【华为云IoT】读书笔记之《万物互联:物联网核心技术与安全》第3章(下)
The new energy track has high risks, so please pay attention to safety
Crud code practice of user management based on koa2 + MySQL
Three programming implementations to quickly determine whether the site is alive
开发第一个Flink应用
SAP AppGyver 的 Universal Theme System 使用介绍
Virtual CPU and memory in yarn (CDH)
c# treeView 树形结构递归处理(企业集团型层次树形展示)
LeetCode 2331. 计算布尔二叉树的值(树的遍历)
Bazel use tutorial to
LeetCode 2319. 判断矩阵是否是一个 X 矩阵
各厂商的数据湖解决方案
Effectively understand FreeSQL wheredynamicfilter and deeply understand the original design intention [.net orm]
KunlunBase 线上Meetup等您来~
读已提交级别下 注解事务+分布式锁结合引起的事故--活动购买机会的错乱
NAT技术及NAT ALG
[Acwing]第 60 场周赛 B- 4495. 数组操作
Autojs learning - multi function treasure chest - medium
Autojs learning - Dynamic decryption