武汉科技大学网络赛1578: LAMP
2016-04-18 20:48
387 查看
1578: LAMP
Time Limit: 1 Sec Memory Limit: 128 MB64bit IO Format: %lld
Submitted: 12 Accepted: 6
[Submit][Status][Web
Board]
Description
Pang Pang is absored in Linux now, he enjoys using LAMP(Linux + Apache + MySQL + php), and runs a great blog on it! One day, the chief of the Pang Pang's hometown found him by his homepage, and send a email to him.The chief asked him to solve the problem of lamp(not LAMP): The main road of the country has a lot of street lamps, which make the road beautiful at night. But at the same time, the cheif noticed that the light of the lamp overlap at many places, which will
cost lots of electricity. However when the chief tried to turn down the lamps, some place were not lit. So he asked Pang to alter the brightness of all the lamps, to make sure that everywhere of the street could be lit up, and minimize the distance of each
lamp could light up.
Input
Multiply test cases, terminate with EOF. The descriptions of the test cases follow:The first line of each test case contains integers N and M (0 < N < 10000 < M < 32768). We assume that the length of the main road is M meters, starts from point 0 and ends at point M. There are N lamps on the road.
The following line contains N integers seperated by single space - the distance between the start point and the i-th street lamp.
Output
For each test case, output one line with a single real number, rounded to two decimal places.
Sample Input
7 15 14 5 2 7 9 14 1 5 20 1 7 12 18 4
Sample Output
2.50 3.00
//贪心就行,只不过要注意路灯到最左最右边的距离 #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> const int maxn = 10005; using namespace std; int lamp[maxn]; int main() { int n,m; while(scanf("%d %d", &n, &m) != EOF) { for(int i = 0; i < n; i++) scanf("%d",&lamp[i]); sort(lamp, lamp+n); double ans = (double)max(lamp[0], m - lamp[n-1]); for(int i = 1; i < n; i++) ans = max(ans, (double)(lamp[i]-lamp[i-1])/2); printf("%.2lf\n",ans); } return 0; }
相关文章推荐
- HTTP返回码总结
- 深度思维:网络推广绝不是千篇一律?
- Android笔记之 网络http通信
- BZOJ4538: [Hnoi2016]网络
- libevent高性能网络库源码分析——Reactor模式(二)
- TCP/IP学习笔记(三)——IP,ARP,RARP
- BP神经网络及matlab实现
- Table of Contents - HTTP
- 武汉科技大学网络赛1575: Gingers and Mints
- 飞思卡尔的i.mx6dl开发板上实现nfs网络文件系统挂载操作指南
- Httpclient
- GridView(网络视图)的基本使用
- httpclient + AsyncTask 请求数据 || httpclient + handler 请求数据
- OkHttp深入学习(三)——Cache
- HttpURLConnection 请求网络 || HttpUtils 请求网络
- 论文阅读:End-To-End Memory Networks
- okhttp教程——起步篇
- 论文阅读:Memory Networks
- 【接口测试】接口自动化测试
- 网络编辑器插件ckeditor+ckfinder配置