85分 求调
查看原帖
85分 求调
1218138
molakeser楼主2024/9/17 10:14
#include <bits/stdc++.h>

using namespace std;
#define int long long
const int N=1e5+5;
int n,a[N],b[N],mx;
double w;

signed main(){
    cin>>n>>w;
    w/=100;
    for(int i=1; i<=n; i++){
        cin>>b[i];
    }
    for(int i=1; i<=n; i++){
        a[b[i]]++;
        mx=max(mx,b[i]);
        int t=0,k=i*w;
        if(k==0)k=1;
        bool f=0;
        for(int j=mx;j>=0;j--){
            t+=a[j];
            if(t>=k){
                    f=1;
                cout<<j<<" ";
                break;
            }
        }
        if(!f)
            cout<<-1<<" ";
    }
    return 0;
}
2024/9/17 10:14
加载中...