76分求助!

P1102 A-B 数对

```cpp #include <bits/stdc++.h> #define MX 200000 using namespace std; int a[MX + 10]; int main() { int n,c,i,j; cin >> n >> c; for(i = 1;i <= n;i++) { cin >> a[i]; } sort(a + 1,a + n + 1,greater<int>()); int cnt = 0; for(i = 1;i < n;i++) { for(j = i + 1;j <= n;j++) { if(a[i] - a[j] == c) { cnt++; if(j != n && a[j + 1] != a[j]) break; } } if(a[i] < c) break; } cout << cnt << endl; return 0; } ```
by yinzongrui @ 2023-06-11 19:15:41


呜呜,为什么没人回我
by yinzongrui @ 2023-06-11 19:19:09


@[yinzongrui](/user/1013323) ![](//图.tk/6)您这也太着急了,4分钟大家还没翻开你帖子呢,不可能给你调完。 你这个复杂度不合格吧,需要用更优的算法,请打开题解。
by Terrible @ 2023-06-11 19:20:34


@[Terrible](/user/195942) 谢谢
by yinzongrui @ 2023-06-11 19:25:06


|