我建议你用map做
```cpp
#include <iostream>
#include <map>
using namespace std;
typedef long long LL;
LL a[200001];
map<LL, LL> m;
int main()
{
int n;
LL c;
LL ans = 0;
cin >> n >> c;
for (int i = 1; i <= n; i++)
{
cin >> a[i];
m[a[i]]++;
a[i] -= c;
}
for (int i = 1; i <= n; i++)
ans += m[a[i]];
cout << ans << endl;
return 0;
}
```
(拒绝抄袭,创造美好洛谷)
by Sinetian @ 2023-08-11 23:23:57
不用map也可以
```cpp
#include <bits/stdc++.h>
using namespace std;
map<int,int> b;
long n,c,ans;
int main()
{
int a[INT_MAX];
cin>>n>>c;
for(int i=0; i<n; i++)
{
cin>>a[i];
b[a[i]]++;
}
for(int i=0; i<n; i++)
ans+=b[a[i]+c];
cout<<ans<<"\n";
return 0;
}
```
(拒绝抄袭,创造美好洛谷)
by fuyanchun @ 2023-08-12 14:33:03