point3 wa求调(我开longlong了)
查看原帖
point3 wa求调(我开longlong了)
824349
_nonsense楼主2024/1/22 21:53
#include<iostream>
#include<map>
using namespace std;
map<int, int> ma;
int main(void)
{
	int n, c, x;
	cin>>n>>c;
	for(int i=0; i<n; i++)
	{
		cin>>x;
		if(ma.find(x)==ma.end())
		{
			ma.insert(make_pair(x, 1));
		}
		else
		{
			ma[x]++;
		}
	}
	long long sum=0;
	map<int, int>::iterator it, t;
	for(it=ma.begin(); it!=ma.end(); it++)
	{
		t=ma.find(c+it->first);
		if(t!=ma.end())
		{
			sum+=it->second*t->second;
		}
	}
	cout<<sum;
	return 0;
}
2024/1/22 21:53
加载中...