这个代码为什么会超出时间限制?
输入:
11
3 5
1 4
12 14
8 12
0 6
8 11
6 10
5 7
3 8
5 9
2 13
#include <iostream>
using namespace std;
int n, begin9[1001], end9[1001];
void init()
{
cin >> n;
for (int i = 1; i <= n; i++)
cin >> begin9[i] >> end9[i];
}
void qsort(int x, int y)
{
int i, j, mid, t;
i = x; j = y; mid = end9[(x + y) / 2];
while (i <= j) {
while (end9[i] < mid)
i++;
while (end9[j] > mid)
j--;
}
if (i <= j) {
t = end9[j];
end9[j] = end9[i];
end9[i] = t;
t = begin9[j];
end9[j] = end9[i];
end9[i] = t;
i++;
j--;
}
if (x < j)
qsort(x, j);
if (i < y)
qsort(i, y);
}
void solve()
{
int ans = 0;
for (int i = 1, t = -1; i <= n; i++)
if (begin9[i] >= t) {
ans++;
t = end9[i];
}
cout << ans << endl;
}
int main()
{
init();
qsort(1, n);
solve();
return 0;
}