当前位置:网站首页>【acwing】786. Number k
【acwing】786. Number k
2022-07-07 10:15:00 【percation】
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int q[N];
int n,k;
int qs(int l, int r, int k){
if(l == r) return q[l];
int i = l - 1, j = r + 1, x = q[(l + r)/2];
while(i < j){
while(q[++i] < x) ;// Realize the left section to move forward to the right , The right section advances to the left
while(q[--j] > x) ;
if(i < j) swap(q[i],q[j]);
}
int s1 = j - l + 1;// Find the position of the dividing point in the interval at that time , Due to interval from 0 Start , So add 1
if(k <= s1)// When the number to be queried , When it is on the left of the current dividing point , Then left recursion , Otherwise, right recursion .
return qs(l, j, k);
return qs(j + 1,r, k - s1);
}
int main(){
scanf("%d%d",&n,&k);
for(int i = 0; i < N; i++){
scanf("%d",&q[i]);
}
cout << qs(0,n-1,k) << endl;
return 0;
}
边栏推荐
- Why does the starting service report an error when installing MySQL? (operating system Windows)
- Inno setup packaging and signing Guide
- Pdf document signature Guide
- Appx代码签名指南
- Enterprise practice | construction of banking operation and maintenance index system under complex business relations
- Pytest learning - dayone
- Postman interface test II
- In addition to the objective reasons for overtime, what else is worth thinking about?
- MCU is the most popular science (ten thousand words summary, worth collecting)
- Agile course training
猜你喜欢

The landing practice of ByteDance kitex in SEMA e-commerce scene

Official media attention! The list of top 100 domestic digital collection platforms was released, and the industry accelerated the healthy development of compliance

ISP、IAP、ICP、JTAG、SWD的编程特点

Performance optimization record of the company's product "yunzhujia"

ES类和对象、原型

Chris Lattner, père de llvm: Pourquoi reconstruire le logiciel d'infrastructure ai

Some thoughts on the testing work in the process of R & D

Use of JSON extractor originals in JMeter

中国首款电音音频类“山野电音”数藏发售来了!

高数_第1章空间解析几何与向量代数_向量的数量积
随机推荐
The story of Plato and his three disciples: how to find happiness? How to find the ideal partner?
Google Colab装载Google Drive(Google Colab中使用Google Drive)
Can I open a stock trading account online? Is it safe
【剑指Offer】42. 栈的压入、弹出序列
Appx code signing Guide
Using keras in tensorflow to build convolutional neural network
Deconvolution popular detailed analysis and nn Convtranspose2d important parameter interpretation
网上可以开炒股账户吗安全吗
Agile course training
Word自动生成目录的方法
位操作==c语言2
Some test points about coupon test
Use of JSON extractor originals in JMeter
Win10 installation vs2015
Es classes and objects, prototypes
Fiddler break point
Internship log - day07
Mongodb creates an implicit database as an exercise
高数_第1章空间解析几何与向量代数_向量的数量积
.NET配置系统
