P7072 [CSP-J2020] 直播获奖

原题链接

题解

太巧妙了!!

code

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,w;
    cin>>n>>w;
    int score[605]={0};
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        score[x]++;
        int sum=0;
        for(int j=600;j>=0;j--)
        {
            sum+=score[j];
            if(sum>=max(i*w/100,1))
            {
                cout<<j<<" ";
                break;
            }
        }
    }
    return 0;
}

posted @ 2024-03-09 19:15  纯粹的  阅读(73)  评论(0)    收藏  举报