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 <cstdio>
#include <map>
using namespace std;
map<long long,int> mp;
int main(){
int n,l;
scanf("%d %d",&n,&l);
for (int i=0; i<n; i++) {
int t;
scanf("%d",&t);
mp[t-l]++;
mp[t+l]--;
}
int hi = 0;
long long ret = 0;
auto it = mp.begin();
for (auto &i : mp){
hi += i.second;
it++;
if(hi > 1 && it != mp.end()) ret += it->first - i.first;
}
printf("%lld",ret);
}
# | 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... |