你确定n方过百万?
by qkm66666 @ 2019-04-27 18:08:59
首先long int和int没有区别
by 幻影学霸刘 @ 2019-06-28 20:43:45
其次我也是最后两个点TLE
```
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
int n,d,t=0;
cin>>n>>d;
int a[1048576];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
sort(a,a+n);
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
if(a[j]-a[i]<=d)
{
t++;
}
}
}
cout<<t;
return 0;
}
```
by 幻影学霸刘 @ 2019-06-28 20:44:17
#include<bits/stdc++.h>
using namespace std;
int n,d,p[9999999],a,b,ans=0;
int main()
{
cin>>n>>d;
for(int i=1;i<=n;i++){cin>>p[i];}
sort(p+1,p+1+n);
for(int i=1;i<n;i++)
{
a=p[i];
for(int j=i+1;j<=n;j++)
{
if(a+d>=p[j]) ans++;
}
}
cout<<ans;
return 0;
}
by 已注销&M73*K7U @ 2019-09-14 13:16:45
@[迷失在黑夜里](/space/show?uid=201565)
欲丰展?使MD
by 酱紫林 @ 2019-10-07 11:40:05