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<stdio.h>
#include<algorithm>
using namespace std;
int n,l,b[150005],t[150005],dap;
void make_dap(){
//int ;
}
void f(int cnt){
if(cnt==n){
make_dap();
return ;
}
t[cnt]=0;
f(cnt+1);
t[cnt]=1;
f(cnt+1);
}
int main(){
int i;
scanf("%d %d",&n,&l);
for(i=0;i<n;i++) scanf("%d",&b[i]);
sort(b,b+n);
/*if(n<=15){
f(0);
printf("%d\n",dap);
return 0;
}*/
for(i=1;i<n;i++){
if(b[i-1]+l<=b[i]-l) continue;
dap+=b[i-1]-b[i]+l*2;
}
printf("%d\n",dap);
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... |