#include <cstdio>
#include <map>
using namespace std;
map<int,int> mp;
int a[100005];
int main(){
int n,l;
scanf("%d %d",&n,&l);
for (int i=0; i<n; i++) {
scanf("%d",&a[i]);
mp[a[i]-l]++;
mp[a[i]+l]--;
}
int hi = 0, 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("%d",ret);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1604 KB |
Output is correct |
2 |
Correct |
0 ms |
1604 KB |
Output is correct |
3 |
Correct |
0 ms |
1604 KB |
Output is correct |
4 |
Correct |
0 ms |
1604 KB |
Output is correct |
5 |
Correct |
0 ms |
1604 KB |
Output is correct |
6 |
Incorrect |
0 ms |
1604 KB |
Output isn't correct |
7 |
Correct |
0 ms |
1604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1736 KB |
Output is correct |
2 |
Correct |
0 ms |
1736 KB |
Output is correct |
3 |
Correct |
0 ms |
1736 KB |
Output is correct |
4 |
Correct |
0 ms |
1736 KB |
Output is correct |
5 |
Correct |
0 ms |
1736 KB |
Output is correct |
6 |
Correct |
0 ms |
1736 KB |
Output is correct |
7 |
Correct |
0 ms |
1736 KB |
Output is correct |
8 |
Correct |
1 ms |
1736 KB |
Output is correct |
9 |
Correct |
0 ms |
1736 KB |
Output is correct |
10 |
Correct |
0 ms |
1736 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
62 ms |
7148 KB |
Output is correct |
2 |
Correct |
120 ms |
10316 KB |
Output is correct |
3 |
Runtime error |
90 ms |
10972 KB |
SIGSEGV Segmentation fault |
4 |
Runtime error |
90 ms |
10972 KB |
SIGSEGV Segmentation fault |
5 |
Correct |
123 ms |
10976 KB |
Output is correct |
6 |
Runtime error |
91 ms |
10708 KB |
Program hung waiting for input |
7 |
Correct |
9 ms |
2528 KB |
Output is correct |
8 |
Correct |
126 ms |
10976 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
2528 KB |
Output is correct |
2 |
Correct |
119 ms |
10316 KB |
Output is correct |
3 |
Correct |
96 ms |
8732 KB |
Output is correct |
4 |
Correct |
67 ms |
7148 KB |
Output is correct |
5 |
Runtime error |
116 ms |
10972 KB |
SIGSEGV Segmentation fault |
6 |
Runtime error |
118 ms |
10972 KB |
SIGSEGV Segmentation fault |
7 |
Correct |
140 ms |
10712 KB |
Output is correct |
8 |
Correct |
128 ms |
10976 KB |
Output is correct |
9 |
Runtime error |
124 ms |
10972 KB |
SIGSEGV Segmentation fault |
10 |
Runtime error |
99 ms |
10972 KB |
SIGSEGV Segmentation fault |
11 |
Correct |
132 ms |
10976 KB |
Output is correct |
12 |
Correct |
119 ms |
10976 KB |
Output is correct |
13 |
Runtime error |
92 ms |
10972 KB |
SIGSEGV Segmentation fault |
14 |
Runtime error |
97 ms |
10972 KB |
SIGSEGV Segmentation fault |
15 |
Runtime error |
100 ms |
10972 KB |
SIGSEGV Segmentation fault |