下载数据都是一样的为什么wa啊???
查看原帖
下载数据都是一样的为什么wa啊???
1056768
pencil1024楼主2024/2/24 15:20
#include <bits/stdc++.h>

#define x first
#define y second

using namespace std;

typedef long long LL;

const int N = 2e5+10;

LL n,C,ans;
int a[N];
unordered_map<LL,LL> has;

int main()
{
	cin>>n>>C;
	for(int i=0;i<n;i++)	//hash表里面存的是答案 
	{
		cin>>a[i];
		has[a[i]]++;
	}
	
	for(auto h : has)
	{
		LL num=h.x, cnt=h.y;
		if(has[num+C])	ans+=cnt*has[num+C];
	}
	cout<<ans;
	
	return 0;
}
2024/2/24 15:20
加载中...