求大佬指教T2
  • 板块灌水区
  • 楼主SKYSELF
  • 当前回复10
  • 已保存回复10
  • 发布时间2020/11/7 16:45
  • 上次更新2023/11/5 08:38:03
查看原帖
求大佬指教T2
121657
SKYSELF楼主2020/11/7 16:45
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
inline int in(){
	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 out(int x){
    if(x<0){
    	putchar('-');
		x=-x;
	}
    if(x>9)
		out(x/10);
    putchar(x%10+'0');
}
bool cmp(int a,int b){
	return a>b;
}
int n,w,a[601],p,num[1000001],len;
int main(){
	n=in();w=in();
	for(int i=1;i<=n;i++){
		int x=in();
		if(a[x]==0){
			num[++len]=x;
			sort(num+1,num+1+len,cmp);
		}
		a[x]++;
		p=max(1,i*w/100);
		for(int i=1;i<=len;i++){
			if(p<=a[num[i]]){
				printf("%d ",num[i]);
				break;
			}
			else p-=a[num[i]];
		}
	}
	return 0;
}

请问这种sort有无风险?跪求大佬

2020/11/7 16:45
加载中...