这个为什么才42分,求大佬指点

#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m,x;
map<int,int>ma;
signed main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		ma[x]++;
	}
	int t=1,cnt=0;
	while(ma.count(t)!=0)
	{
		if(t==1)
		cnt+=ma[1];
		else
		{
			cnt+=min(ma[t],ma[t-1]);
		}
		t++;
	}
	cout<<cnt<<endl;
	return 0;
}

全部评论
6 4 1 2 2 2 3 3  轻松hack
2 回复 分享
发布于 2024-08-05 09:08 天津
你需要更新ma[t]的数,从而让经验值更大的一定要小于前面连续最小的
点赞 回复 分享
发布于 2024-08-05 16:53 福建

相关推荐

07-18 13:49
门头沟学院 Java
26小林不会梦到感谢...:这个点还在面暑期嘛不是马上开秋招了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务