这个AC了 但是会有n=1的数据吗
查看原帖
这个AC了 但是会有n=1的数据吗
426631
Exsinly楼主2024/10/26 21:35
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 1e5 + 10;
LL r[MAXN]; 
LL n;
LL cnt = 0;
int main()
{	
	//freopen("t1.in","r",stdin);
	//freopen("t1.out","w",stdout); 
	cin >> n;
	for (int i = 1 ; i <= n ; ++i) cin >> r[i];
	sort(r+1,r+n+1);
	LL pos = 2;
	while(r[pos] <= r[1]) pos++;
	LL k = 1;
	while (pos != n + 1)
	{
		if (r[pos] > r[k])
		{
			k++;
			pos++;
			cnt++;
		}
		else pos++;
	}
	//cout << cnt << endl;
	LL ans = n - cnt;
	cout << ans << "\n";
	return 0;
}

2024/10/26 21:35
加载中...