【蓝桥杯每日一题】3.5 牛的学术圈I

原题链接:3745. 牛的学术圈 I - AcWing题库

原题条件:
  • h指数等于使得研究员有至少 h h h篇引用次数不少于h的论文的最大整数h
  • 综述对于文献的引用最多引用一次,且 L < = N L<=N L<=N
思考:

根据“至少有h篇”,可得出h一定不会超过总篇数N,故在得出h的数值时,循环只需循环到N即可。

对于 :

4 1
1 100 3 3

这样的带有重复的数值,综述引用第三或者第四个 3 3 3,对于最终结果来说并没有影响,故利用桶结构对研究文献数组 c c c进行统计

AC代码:

#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int tong[100010];
int N,L;
int temp=0; //临时变量
int main()
{
	cin>>N>>L;
	
	for(int i=1;i<=N;i++)
	{
		cin>>temp;
		tong[temp]++;
	}
	
	int ans=0;
	temp=N;
	
	for(ans=0;ans<N;ans++) //由于h指数的定义,h指数不会大于论文总数
	{
		temp-=tong[ans]; //temp表示:引用量 > ans 的文章的篇数
		if(temp+min(tong[ans],L)<=ans) break;
        //temp + min(cnt[ans], L) 表示:引用量包括ans的或是加上L个引用之后引用量> ans的文章的篇数
	}
	cout<<ans<<endl;
	
	return 0;
}

注:
t e m p − = t o n g [ a n s ] temp -= tong[ans] temp=tong[ans], t e m p temp temp表示的就是 > a n s ans ans 的 的个数,而它能改变的就是当前的 a n s ans ans,使他成为 a n s + 1 ans + 1 ans+1,最多是 m i n ( t o n g [ a n s ] , l ) min(tong[ans], l) min(tong[ans],l)次, t e m p + m i n ( t o n g [ a n s ] , l ) temp + min(tong[ans], l) temp+min(tong[ans],l) 就是> a n s ans ans更改后的个数。

  • 9
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值