这个为什么才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 福建

相关推荐

joecii:如果没有工资,那可能没有工资是这家公司最小的问题了
找实习记录
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
2025-12-05 11:50
腾讯云智 后台开发 13x16+1x12+24 本科其他
码农索隆:在牛客,我只能说老弟,你还得练,但是现实生活,我直接滑跪,让你教教我
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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