1 条题解
-
0
zhuyichen LV 7 MOD @ 2025-07-25 14:22:42
// 计数排序 + 遍历 O(n+A) #include <bits/stdc++.h> using namespace std; #define F(i, x, y) for (int i = (x); i <= (y); i++) #define DF(i, x, y) for (int i = (x); i >= (y); i--) #define PII pair<int,int> const int N = 1e7+10,M = 2e7+10; int n,C; int num[M]; int rd() { int x = 0; int f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = - 1; for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48); return x *= f; } signed main() { // freopen("input.in","r",stdin); cin>>n>>C; F(i,1,n) { int x;x=rd(); num[x]++; } int sum = 0; F(B,1,20000000 - C) { int A = B + C; sum += num[A] * num[B]; } cout<<sum; return 0; }
- 1
信息
- ID
- 1004
- 难度
- 9
- 分类
- (无)
- 标签
- 递交数
- 16
- 已通过
- 2
- 通过率
- 12%
- 上传者