-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlamp.c
More file actions
36 lines (28 loc) · 649 Bytes
/
lamp.c
File metadata and controls
36 lines (28 loc) · 649 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//
// Created by xiao on 2017/11/20.
//
#include <stdio.h>
#include <stdlib.h>
int compare (const void * a, const void * b){
return *((int *)a) - *((int *)b);
}
int main(){
int n, l;
scanf("%d%d", &n, &l);
int lamps[n];
for (int i = 0; i < n; ++i) {
scanf("%d", &lamps[i]);
}
qsort(lamps, n, sizeof(int), compare);
double max = lamps[0];
for (int i = 0; i < n - 1; ++i) {
if(max < 1.0*(lamps[i + 1] - lamps[i])/2){
max = 1.0*(lamps[i + 1] - lamps[i])/2;
}
}
if (max < l - lamps[n-1]){
max = l - lamps[n-1];
}
printf("%.2f", max);
return 0;
}