set85分小错求助
查看原帖
set85分小错求助
444195
caramel_qwq楼主2022/7/18 20:12

用的set容器解法,但是#9,#11,#15一直不过,求改错

#include<bits/stdc++.h>
using namespace std;
int n,w,tmp,a[608];
class cmp{
	public:
	bool operator()(int a,int b){
		return a>b;
	}
};
set<int,cmp> s;
int main(){
	scanf("%d%d",&n,&w);
	for(int i=1;i<=n;i++){
		scanf("%d",&tmp);
		s.insert(tmp);
		a[tmp]++;
		int x=floor(i*double(w/100.00));
		int h=max(1,x);
		int k=0;
		for(set<int,cmp>::iterator it=s.begin();it!=s.end();it++){
			k+=a[*it];
			if(k>=h){
				printf("%d ",*it);
				break;
			}
		}
	}
	printf("\n");
	return 0;
}
2022/7/18 20:12
加载中...