From 80d695997af501fb6cc486199983c698bf6df85d Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Thu, 15 Oct 2020 19:54:14 +0800 Subject: [PATCH] =?UTF-8?q?P1102=20A-B=20=E6=95=B0=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R39856779 --- problem/P1102/P1102.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 problem/P1102/P1102.cpp diff --git a/problem/P1102/P1102.cpp b/problem/P1102/P1102.cpp new file mode 100644 index 00000000..b7d973fc --- /dev/null +++ b/problem/P1102/P1102.cpp @@ -0,0 +1,19 @@ +#include + +using namespace std; + +int main() { + long long n, c, ans = 0; + int a[200005]; + map 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; +}