代码:
#include <bits/stdc++.h>
using namespace std;
int a[100007], n, s, w;
inline int read()
{
int s = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9')
{
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
{
s = s * 10 + ch - '0';
ch = getchar();
}
return s * f;
}
inline void write(int x)
{
if (x < 0)
{
putchar('-');
x = -x;
}
if (x > 9)
write(x / 10);
putchar(x % 10 + '0');
}
int main()
{
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
s = read();
w = read();
for (register int i = 1; i <= s; i++)
{
int x;
x = read();
register int j = n;
while (j >= 1 && a[j] < x)
a[j + 1] = a[j], j--;
a[j + 1] = x;
n++;
write(a[max(1, int(n * w / 100.0))]);
putchar(' ');
}
// system("pause");
return 0;
}
使用我能力范围内的所有优化了,还是比较卡边(我是卡边之王(伦敦大雾))