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>
#define MIN -1000000001
using namespace std;
int n,l,lamp[150001];
int main (void)
{
int i,cnt=0,prv=MIN;
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>max(prv,lamp[i]-l)){
cnt+=lamp[i-1]+l-max(prv,lamp[i]-l);
prv=lamp[i-1]+l;
}
}
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... |