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 lamp[150001],n,l;
int main (void)
{
int i,cnt=0;
scanf("%d %d",&n,&l);
for(i=0;i<n;i++){
scanf("%d",&lamp[i]);
}
sort(lamp,lamp+n);
for(i=1;i<n;i++){
if(lamp[i-1]+l>lamp[i]-l)
cnt+=lamp[i-1]+l-(lamp[i]-l);
if(i>=2 && lamp[i-2]+l>lamp[i]-l)
cnt-=lamp[i-2]+l-(lamp[i]-l);
//printf("%d\n",cnt);
}
printf("%d\n",cnt);
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... |