用冒泡WA + TLE了
Code:
#include <bits/stdc++.h>
using namespace std;
int score[100010];
bool cmp(int x, int y)
{
return x > y;
}
int main()
{
int n, w;
cin >> n >> w;
int ex = 0;
for(int i = 1; i <= n; i++)
{
cin >> score[i];
for(int j = i; j > 1; j--)
{
if(cmp(score[j], score[j - 1]))
{
swap(score[j], score[i - 1]);
}
}
for(int j = 1; j < n; j++)
{
if(cmp(score[j + 1], score[j]))
{
swap(score[j + 1], score[j]);
}
}
ex = max(1, i * w / 100);
cout << score[ex] << ' ';
}
return 0;
}