이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<stdio.h>
#include<algorithm>
using namespace std;
int n, L, i, w[151000], ed, b, e;
long long Res;
int main(){
scanf("%d%d", &n, &L);
for (i = 1; i <= n; i++){
scanf("%d", &w[i]);
}
sort(w + 1, w + n + 1);
ed = -2100000000;
for (i = 1; i < n; i++){
if (w[i] + L < w[i + 1] - L)continue;
b = w[i + 1] - L, e = w[i] + L;
if (e <= ed)continue;
if (ed < b)ed = b;
Res += e - ed;
ed = e;
}
printf("%lld\n", Res);
}
| # | 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... |