This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
long long solve_D(){
int n,d,m;
cin>>n>>d>>m;
vector<int> a(n);
for(auto &i:a)cin>>i;
sort(a.begin(),a.end());
int p = 0;
long long res = 0;
for(int i=0;i<n;i++){
while(p < i && a[i]-a[p] > d)p++;
res += i-p;
}
return res;
}
int main(){
int b;
cin>>b;
if(b == 1)cout<<solve_D()<<'\n';
else cout<<"to do\n";
return 0;
}
/*
1 6 5 100
10 20 23 25 50 50
1
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |