这题数据是真的蒻

P1923 【深基9.例4】求第 k 小的数

5k_sync_closer @ 2021-08-13 06:50:37

甚至连O2都不用开,卡卡常就行。

#include <cstdlib>
#include <cstdio>
inline int read()
{
    register int r(0);register char c(getchar());
    while(c < '0' || c > '9') c = getchar();
    while(c >= '0' && c <= '9') r = r * 10 + c - '0', c = getchar();
    return r;
}
inline int out(int x)
{
    if(x >= 10) out(x / 10);
    putchar(x % 10 + '0');
}
inline int comp(const void *a,const void *b)
{
    return *(int*)a - *(int*)b;
}
int main()
{
    register int a[5000001], n(read()), k(read());
    for(register int i(0);i < n;++i)
        a[i] = read();
    qsort(a, n, 4, comp);
    out(a[k]);
    return 0;   
}

记录


by _QrSn_ @ 2021-08-13 07:43:03

用户名危(


by Union_of_Britain @ 2021-08-13 07:55:46

@强人锁男 危个der


by Waaifu_D @ 2021-08-13 09:55:14

@kkkkksc03 这题只用sort都行


by 00001x @ 2021-08-18 18:16:59

@Waaifu_D 他只爱用最麻烦的方式写


|