数对

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
#define x first
#define y second
const int N = 1e7 + 10;
map<int,int>m;
int a[N];
int main() 
{
	int n, k;
	cin >> n >>k;
	for(int i = 0; i < n; i ++)
	{
		cin >>a[i];
		m[a[i]] ++;
		a[i] -= k;
	}
	LL ans = 0;
	for(int i = 0; i < n; i ++)
	{
		ans += m[a[i]];
	}
	cout << ans << endl;
	return 0;
}

全部评论

相关推荐

点赞 评论 收藏
分享
2025-12-13 14:51
已编辑
井冈山大学 算法工程师
龙虾x:算法比你强的没有你美,比你美的…..算了已经没有比你美的了
工作两年想退休了
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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