rt,题目
代码只有92分,不知道为啥
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
char *p1,*p2,buf[1<<20+5];
inline int read(){
int x=0;
char c=gc();
while(!isdigit(c)){
c=gc();
}while(isdigit(c)){
x=x*10+(c^48);
c=gc();
}return x;
}
const int N = 2e5 + 5;
int n, c;
map<long long, long long> m;
int a[N];
long long res;
int main()
{
int cnt = 0, cnt1 = 0;
n = read(), c = read();
for (int i = 1; i <= n; i ++ )
{
a[i] = read();
if (a[i] >= c) m[a[i]] ++ , a[i] -= c;
}
/* for (int i = 1; i <= n; i ++ )
if (a[i] > c)
b[++ b[0]] = a[i];
else if (a[i] == c) cnt ++ ;
for (int i = 1; i <= n; i ++ )
if (a[i] == 0)
cnt1 ++ ;
sort(b + 1, b + n + 1);
for (int i = n; i >= 1; i -- )
{
if (b[i] < c) break;
for (int j = 1; j <= i; j ++ )
if (b[i] - b[j] == c) res ++ ;
else if (b[i] - b[j] < c) break;
}
res += cnt1 * cnt;*/
for (int i = 1; i <= n; i ++ ) res += m[a[i]];
printf("%lld\n", res);
return 0;
}