HDU 5073 Galaxy
2015-10-19 19:35
405 查看
Galaxy
Time Limit: 1000msMemory Limit: 262144KB
This problem will be judged on HDU. Original ID: 5073
64-bit integer IO format: %I64d Java class name: Main
Special Judge
Good news for us: to release the financial pressure, the government started selling galaxies and we can buy them from now on! The first one who bought a galaxy was Tianming Yun and he gave it to Xin Cheng as a present.
#include <bits/stdc++.h> using namespace std; using LL = long long; const int maxn = 50010; LL s[maxn],ss[maxn],a[maxn]; int main(){ int kase,n,k; scanf("%d",&kase); while(kase--){ scanf("%d%d",&n,&k); for(int i = 1; i <= n; ++i) scanf("%I64d",a + i); if(n == k){ puts("0"); continue; } sort(a + 1,a + n + 1); for(int i = 1; i <= n; ++i){ s[i] = s[i-1] + a[i]; ss[i] = ss[i-1] + a[i]*a[i]; } LL ret = 0x3f3f3f3f3f3f3f3f; for(int i = 0; i <= k; ++i){ LL tmp = (ss[i + n - k] - ss[i])*(n-k); ret = min(ret,tmp - (s[i + n - k] - s[i])*(s[i + n - k] - s[i])); } printf("%.12f\n",ret*1.0/(n-k)); } return 0; }
View Code
相关文章推荐
- 数据请求常规操作步骤
- C语言基础
- Android Studio如何设置代码自动提示
- 关于伪基站的攻击
- sift尺度空间的理解以及计算
- CLR 无法从 COM 上下文 0x208f68 转换为 COM 上下文 0x2090d8,这种状态已持续 60 秒
- linux下的网卡eth0配置详解
- 专访吴恩达:我不关心人工智能是否变邪恶
- 第十三周第一天
- Android进阶笔记05:View、SurfaceView 和GLSurfaceView 的关系和区别
- LeetCode 10: Regular Expression Matching
- IOS开发之----让UILabel 垂直方向顶端对齐的代码
- int型转二进制,八进制,十六进制查表法
- 151019总结
- android studio快捷键大全
- Swift:函数和闭包
- 类与对象
- int型转二进制,八进制,十六进制查表法
- nodejs微信开发--设置自定义菜单
- Qt:QT中PRO文件写法的详细介绍