2017 ecfinal b题
来源:互联网 发布:网络舆论利大于弊一辩 编辑:程序博客网 时间:2024/04/29 10:41
要好好学英语啊,不然题目都读不懂啊。
code:
#include<stdio.h>#include<algorithm>using namespace std;#include<queue>using namespace std;struct node{ int ge; double zhi; double ans; bool operator <(const node& a)const { if(ans!=a.ans) { return a.ans>ans; } }} a[300000];priority_queue<node>N;int main(){ int t; scanf("%d",&t); int cas=1; while(t--) { int n,m; scanf("%d%d",&n,&m); double sum=0; int mm=m; for(int i=0; i<n; i++) { scanf("%lf",&a[i].zhi); sum+=a[i].zhi; a[i].ge=1; m--; a[i].ans=(a[i].zhi/a[i].ge)*(a[i].zhi/a[i].ge)*a[i].ge-(a[i].zhi/(a[i].ge+1))*(a[i].zhi/(a[i].ge+1))*(a[i].ge+1); N.push(a[i]); } sum/=mm; while(m) { node aa=N.top(); N.pop(); aa.ge++; m--; aa.ans=(aa.zhi/aa.ge)*(aa.zhi/aa.ge)*aa.ge-(aa.zhi/(aa.ge+1))*(aa.zhi/(aa.ge+1))*(aa.ge+1); N.push(aa); } double anss=0; while(!N.empty()) { node aa=N.top(); N.pop(); anss+=(aa.zhi/aa.ge-sum)*(aa.zhi/aa.ge-sum)*aa.ge; } printf("Case #%d: %.12f",cas++,anss/mm); }}/*313 61 2 35 105 6 7 8 96 61 1 4 5 1 4*/
代码还不知道是否可以ac,待测。
阅读全文
0 0
- 2017 ecfinal b题
- UVALive 7511 2015ECfinal
- ECfinal UVALive 7512 November 11th (公式)
- UVALive 7505 Hungry Game of Ants (2015Ecfinal)
- UVALive 7505 Hungry Game of Ants ACM/ICPC ECFinal 2015(dp+思维)
- B题
- B题
- 2017年院赛B题 N个数求和
- 2017山东省赛B题Quadrat
- 2017电赛B题代码
- Kickstart Round B 2017 Problem B. Center
- (2017/4、8、/ B
- 2017 CCPC秦皇岛 B
- 资格赛b题
- 搜索比赛B题
- 省赛1B题
- 南邮OJ B题
- 2010湖南省B题
- Python 读写当前路径下文件错误 UnboundLocalError: local variable 'file' referenced before assignment
- bootstrap3 datepicker 和moment.js的汉化
- WinCap数据包显示
- 虚拟机:centos上不了网的解决
- 跳跃游戏 动态规划
- 2017 ecfinal b题
- 关于String str =new String("abc")和 String str = "abc"的比较
- 软件和硬件都是对生活的高度抽象---论中断控制
- android 40条知识
- SpringBoot入门-11(springboot配置jsp模板)
- Angularjs购物车计算价格例子
- python3 文件操作
- 动态点分治系列(幻想乡战略游戏、开店、小清新数据结构题)
- Hadoop YARN配置参数剖析(4)—Fair Scheduler相关参数