76分求助,大佬救命
  • 板块P1102 A-B 数对
  • 楼主Clovtong
  • 当前回复1
  • 已保存回复1
  • 发布时间2025/1/14 19:22
  • 上次更新2025/1/15 08:19:50
查看原帖
76分求助,大佬救命
1386326
Clovtong楼主2025/1/14 19:22

2,3,4测试点超时,其余AC

#include <bits/stdc++.h>
using namespace std;
int n , c , a[int(2e5+5)] , ans;
bool cmp(int x , int y)
{
	return x>y;
}
int main()
{
	cin>>n>>c;
	for(int i = 1 ; i<=n ; i++) cin>>a[i];
	sort(a+1,a+n+1,cmp);
	for(int i = 1 ; i<n ; i++)
	{
		for(int j = i+1 ; j<=n ; j++)
		{
			if(a[i]-a[j]==c)
			{
			//	cout<<i<<" "<<j<<";";
				ans++;
			}
		}
	}
	cout<<ans;
	return 0;
}
2025/1/14 19:22
加载中...