0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:31:59 +00:00

P1102 A-B 数对

R39856779
This commit is contained in:
Baoshuo Ren 2020-10-15 19:54:14 +08:00 committed by Baoshuo Ren
parent 22662275f5
commit 80d695997a
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

19
problem/P1102/P1102.cpp Normal file
View File

@ -0,0 +1,19 @@
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, c, ans = 0;
int a[200005];
map<int, int> b;
cin >> n >> c;
for (int i = 1; i <= n; i++) {
cin >> a[i];
b[a[i]]++;
}
for (int i = 1; i <= n; i++) {
ans += b[a[i] + c];
}
cout << ans << endl;
return 0;
}