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 <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;
int main()
{
long long N, L;
cin >> N >> L;
L *= 2;
vector<long long> V(N);
for (int i=0; i<N; i++) {
cin >> V[i];
}
sort(V.begin(), V.end());
long long p1 = -999999999;
long long p2 = -999999999;
long long res = 0;
for (int i=0; i<N; i++) {
res += max(0LL, p2 - max(p1, V[i]));
p1 = max(p2, V[i]);
p2 = V[i] + L;
}
cout << res << endl;
}
# | 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... |