can anyone tell me, why this code of mine is not getting TLE ?
it got accepted with time 0.13 s.
but if i consider input like:
65000 1
(all numbers same)
for this the solution must be TLE right ?
#include<iostream>#include <algorithm>using namespace std;int main(){int n,k,i,j,a[65001],count=0;cin>>n>>k;for(i=1; i<=n; i++){cin>>a[i];}sort(a+1,a+n+1);for(i=1; i<n; i++){for(j=i+1; j<=n; j++){if((a[j]-a[i])>=k){count=count+n-j+1;break;}}}cout<<count<<"\n";}
Read more… (41 words)