超时有办法优化吗
查看原帖
超时有办法优化吗
1244320
Delayed楼主2024/8/14 10:34
#include<bits/stdc++.h>
using namespace std;
const int N=10000+10;
int n,a[N],w;
bool cmp(int x,int y) 
{
	return x>y;

}
int main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n>>w;
	for(int i=1; i<=n; i++) 
	{
		cin>>a[i];
		int people=max(i*w/100,1);
		for(int j=1; j<=i; j++) {
			sort(a+1,a+i+1,cmp);
			cout<<a[people]<<" ";
			break;
		}
	}
}
2024/8/14 10:34
加载中...