社区讨论

为什么?

P7072[CSP-J 2020] 直播获奖参与者 4已保存回复 15

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
15 条
当前快照
1 份
快照标识符
@lo19cadw
此快照首次捕获于
2023/10/22 17:19
2 年前
此快照最后确认于
2023/11/02 17:20
2 年前
查看原帖
这份 die 码:
CPP
#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
但是如果你这么写
CPP
#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 分,望大神解答为什么会这样。

回复

15 条回复,欢迎继续交流。

正在加载回复...