为啥TLE了!!!!!QAQ

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

BIOSS @ 2024-12-16 14:50:20

求助大大们,小菜鸡搞不懂为啥TLE了

#include <bits/stdc++.h>
using namespace std;
#define maxn 1000120
int a[5000005];

int main() {
    int n;
    int l;
    scanf("%d%d", &n, &l);

//  cin >> l;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    printf("%d", a[l]);
    return 0;
}

by linken @ 2024-12-16 15:03:55

数组开longlong


by linken @ 2024-12-16 15:04:46

输入全用scanf


by YYC_coding @ 2024-12-20 12:20:16

main函数开头加上:

std::ios::sync_with_stdio(0);
std::cin.tie(nullptr);

|