跳过正文
题解:P10292 [CCC 2024 J3] Bronze Count

题解:P10292 [CCC 2024 J3] Bronze Count

xyx404
作者
xyx404
Have a nice day.

封面

思路:
#

使用桶进行储存,然后从最大的分数从小历遍,当现在是第三个有值的,这就是铜牌,然后输出分数和人数就可以了。

代码:
#

#include<bits/stdc++.h>
#define LL long long
#define CPPname using namespace std
CPPname;
int tong[76],n,tamp;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>tamp;
		tong[tamp]++;// 使用桶进行储存 
	}
	tamp=0;//计算是第几大的 
	for(int i=75/* 题目中保证每个分数在 75 以下 */;i>=0/* 题目中保证每个分数在 0 以上 */;i--){
		if(tong[i]!=0)tamp++;
		if(tamp==3){
			cout<<i<<" "<<tong[i];
			return 0;
		} 
	}
	return 0;
}