nth_element()是c++的STL库中的函数,作用是将数组中第k小的整数放在区间第k个位置
比如a[6]={2,5,6,4,7,8},使用nth_element(a,a+3,a+6)后,区间中第四个数,也就是a[3],会被放入数组中第四小的数,也就是6( a a a的下标是从0开始的)。
使用一次nth_element()的时间复杂度为 O ( n ) O(n) O(n)
code
#include<bits/stdc++.h>
using namespace std;
int a[6]={
2<