如何解决TLE
#include <iostream>using namespace std;
int Partition(int a[], int low, int high)
{
int pivotkey;
a = a;
pivotkey = a;
while (low < high) {
while (low < high && a >= pivotkey)--high;
a = a;
while (low < high && a <= pivotkey)++low;
a = a;
}
a = a;
return low;
}
void quicksort(int a[], int low, int high) {
if (low < high) {
int pivotloc = Partition(a, low, high);
quicksort(a, low, pivotloc - 1);
quicksort(a, pivotloc + 1, high);
}
}
int main()
{
int n, a, a1 = 1;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a;
}
quicksort(a, a1, n );
for (int i = 1; i <= n; i++)
cout << a<<" ";
return 0;
} 可能是数组分配的内存太大,我把a改小就可以运行了 心驰神往 发表于 2021-1-11 08:44
可能是数组分配的内存太大,我把a改小就可以运行了
可以正常运行,但是luogu上面显示超出时间限制,出来了TLE 1197084193 发表于 2021-1-11 20:23
可以正常运行,但是luogu上面显示超出时间限制,出来了TLE
好吧
页:
[1]