一些性质:h指数 逆序对
作者:互联网
奶牛学术圈https://www.acwing.com/problem/content/3748/
h 指数等于使得研究员有至少 h 篇引用次数不少于 h 的论文的最大整数 h。
有l次机会提高每篇的引用次数+1
求h指数最多可以是多少:
h指数就是从大到小 下标的最右边位置
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int n,l;
const int N = 1e5+10;
int q[N];
int res;
bool check(int x){
int a=0,b=0;
for (int i = 1; i <= n; i ++ ){
if(q[i]>=x) a++;
else if( x-q[i]==1) b++;
}
b=min(l,b);
if(a+b>=x)
return true;
return false;
}
int main()
{
cin >> n>>l;
for (int i = 1; i <= n; i ++ ) cin >> q[i];
sort(q+1,q+1+n,greater<int>());
int l=1,r=n;
while ( l<r ){
int mid=(l+r+1)/2;
if(check(mid)) l=mid;
else r=mid-1;
}
cout << l;
return 0;
}
奶牛体操
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 25;
int f[N][N];
int a[N];
int main()
{
int n,k;
cin >> k>>n;
for (int i = 1; i <= k; i ++ ){
for (int i = 1; i <= n; i ++ ) cin >> a[i];
for (int i = 1; i <= n; i ++ ){
for (int j = i+1; j <=n; j ++ )
f[a[i]][a[j]]++;//邻接矩阵i j存每个第i个数在第j个数前面的次数
}
}
int res=0;
for (int i = 1; i <= n; i ++ ){
for (int j = 1; j <=n; j ++ ){
if(f[i][j]==k) res++;
}
}
cout << res;
return 0;
}
标签:main,const,指数,int,namespace,逆序,return,include,性质 来源: https://www.cnblogs.com/liang302/p/16029223.html