为什么?
查看原帖
为什么?
813622
Igallta楼主2023/9/29 14:25

这份 die 码:

#include<bits/stdc++.h>
using namespace std;
int n,t[1001];
double w;
signed main(){
	ios::sync_with_stdio(0);
	cout.tie(0);
//	freopen("online.in","r",stdin);
//	freopen("online.out","w",stdout);
	cin>>n>>w;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		++t[x];
		int peo=max(1,int(i*w/100));
//		cout<<peo<<'\n';
		for(int j=600;j>=0;j--){
			if(t[j]){
				peo-=t[j];
				if(peo<=0){
					cout<<j<<' ';
					break;
				}
			}
		}
	}
}

就可以AC

但是如果你这么写

#include<bits/stdc++.h>
using namespace std;
int n,t[1001];
double w;
signed main(){
//	freopen("online.in","r",stdin);
//	freopen("online.out","w",stdout);
	cin>>n>>w;
	w/=100;
	for(int i=1;i<=n;i++){
		int x,fs=0;
		cin>>x;
		++t[x];
		int peo=max(1,int(i*w));
		for(int j=600;j>=0;j--){
			if(t[j]){
				peo-=t[j];
				fs=j;
				if(peo<=0)break;
			}
		}
		cout<<fs<<' ';
	}
}

就只有 85 分,望大神解答为什么会这样。

2023/9/29 14:25
加载中...