CSP2020-J-2-直播获奖危险调用60分

#include<bits/stdc++.h>
using namespace std;
int n,w,a[601],b,ans;
int main(){
	freopen("live.in","r",stdin);
    freopen("live.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>w>>b;
	a[b]++;
	cout<<b<<" ";
	for(int i=2;i<=n;i++){
		cin>>b;
		a[b]++;
		ans=0;
		for(int j=600;j>=1;j--){
			ans+=a[j];
			if(ans>=max(1,i*w/100)){
				cout<<j<<" ";
				break;
			}
		}
	}
	return 0;
}

freopen不能ios::sync_with_stdio(0);

求解决方案

2 个赞

给了

3 个赞