This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define ff first
#define ss second
#define ll long long
#define append push_back
#define all(x) (x).begin(),(x).end()
void solvefor1(){
ll r;
int n,m,o,p;
cin>>n>>o>>m;
int dp[m+1]={0};
vector<int> v;
for(int i=0;i<n;i++){
cin>>p;
dp[p]++;
v.append(p);
}
for(int i=1;i<=m;i++)
dp[i]+=dp[i-1];
r=0;
for(auto& i:v)
r+=dp[min(m,i+o)]-dp[max(0,i-o-1)]-1;
cout<<r/2;
}
void solvefor2(){
}
void solvefor3(){
}
void solve(){
int t;
cin>>t;
if(t==1) solvefor1();
if(t==2) solvefor2();
if(t==3) solvefor3();
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
solve();
return 0;
}
# | 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... |