WA了第一个点和第三个不知道哪里错啦
查看原帖
WA了第一个点和第三个不知道哪里错啦
792595
wbw_121124楼主2023/1/7 11:59

可以帮我看看吗???

#include <bits/stdc++.h>
using namespace std;

struct zombie{
	int p,t;
}a[2005];
bool cmp(zombie A,zombie B)
{
	if(A.p==B.p)
	{
		if(A.t>B.t)return false;
		else return true;
	}
	else if(A.p<B.p)return true;
	else return false;
}
int n,sum,b;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i].p>>a[i].t;
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=n;i++)
	{
//		cout<<a[i].p<<" "<<a[i].t<<endl;
		if(a[i].p!=a[i-1].p||a[i].t-b>59||i==n)
		{
			sum++;
			b=a[i].t;
		}
	}
	cout<<sum;
	return 0;
}
2023/1/7 11:59
加载中...