刷数学题不知道为啥出来这个

算是贪心吧,先把所有的power加起来,然后sort一遍,每次删掉最小的那个数,记录一个max,平均值ave如果比max大,就替换,一定要小心m的值可能会比n小,意味着不一定每个例子都是可以全删完,所以有个m>0的判断,这儿卡了好几发。

 #include <iostream>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <stack>
#include <queue>
using namespace std;
const double Pi=3.14159265358979323846;
typedef long long ll;
ll a[+]; int main()
{
ll n,k,m;
cin>>n>>k>>m;
double ave;
ll sumn=;ll sum=;
for(int i=;i<=n;i++)
{
cin>>a[i];
sumn+=a[i];
}
sort(a+,a+n+);
sum=sumn+min(m,k*n);
ave=sum*1.0/n;double max=ave;
for(int i=;i<n&&m>;i++)
{ sumn-=a[i];
sum=sumn+min(--m,(n-i)*k);
ave=sum*1.0/(n-i);
if(ave>max)
max=ave;
}
printf("%.7lf",max);
return ;
}

1111B - Average Superhero Gang Power的更多相关文章

  1. CF-1111B-Average Superhero Gang Power

    首先,对于这题我们要知道要删除一个数使平均值最大一定是删除最小的数,然后我们假设删除操作执行了i次,也就是删除最小的i个数.在已知删除操作次数之后求增加操作的次数就容易了,当然是m - i和k * ( ...

  2. codeforces contest 1111

    A. Superhero Transformation 题意: 元音和元音,辅音和辅音字母之间可以互相转换,问两个字符串是否想同: 题解:直接判断即可: #include<bits/stdc++ ...

  3. CF-1111 (2019/2/7 补)

    CF-1111 题目链接 A. Superhero Transformation tags : strings #include <bits/stdc++.h> using namespa ...

  4. Daily record-August

    August11. A guide dog can guide a blind person. 导盲犬能给盲人引路.2. A guide dog is a dog especially trained ...

  5. AVAudioFoundation(4):音视频录制

    本文转自:AVAudioFoundation(4):音视频录制 | www.samirchen.com 本文主要内容来自 AVFoundation Programming Guide. 采集设备的音视 ...

  6. [TypeScript] Using Assertion to Convert Types in TypeScript

    Sometimes the compiler needs help figuring out a type. In this lesson we learn how to help out the c ...

  7. Display controller

    Field of the Invention The present invention relates to a display controller. Background to the inve ...

  8. Java泛型(6):extends和super关键字

    (1) <T extends A> 因为擦除移除了类型信息,而无界的泛型参数调用的方法只等同于Object.但是我们可以限定这个泛型参数为某个类型A的子集,这样泛型参数声明的引用就可以用类 ...

  9. training 2

    Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.136 Average Precision (AP) @[ IoU ...

随机推荐

  1. 谈一谈JUnit神奇的报错 java.lang.Exception:No tests found matching

    最近在学习Spring+SpringMVC+MyBatis,一个人的挖掘过程确实有点艰难,尤其是有一些神奇的报错让你会很蛋疼.特别是接触一些框架还是最新版本的时候,会因为版本问题出现很多错误,欢迎大家 ...

  2. VIM编辑配置文件基本操作

    vim  /etc/apt/sources.list 按insert键进入编辑状态 编辑完成以后按ESC退出编辑状态 输入 ":"进入命令状态,常用命令: 1.W:write ,写 ...

  3. 蓝桥杯—ALGO-2 最小最大公倍数

    问题描述已知一个正整数N,问从1~N中任选出三个数,他们的最小公倍数最大可以为多少. 输入格式输入一个正整数N. 输出格式输出一个整数,表示你找到的最小公倍数.样例输入9样例输出504数据规模与约定1 ...

  4. MATLAB 图片折腾4

    重新安排矩阵的x,y,z , 在二维中就相当于把x,y 对换,在三维中相当于可以把三个坐标的位置互换. 比如A = A(:,:,1)=repmat(1,3,3);A(:,:,2)=repmat(2,3 ...

  5. Date与时间戳的相互转换(Java)

      1.Date对象转换为时间戳 Date date = new Date(); long times = date.getTime(); System.out.println(times); 效果如 ...

  6. ES6-循环

    forEach 方法来遍历数组,不能使用break语句中断循环,也不能使用return语句返回到外层函数 myArray.forEach(function (value) { console.log( ...

  7. JDK1.8源码逐字逐句带你理解LinkedHashMap底层

    注意 我希望看这篇的文章的小伙伴如果没有了解过HashMap那么可以先看看我这篇文章:http://blog.csdn.net/u012403290/article/details/65442646, ...

  8. error MSB8008: 指定的平台工具集(V120)未安装或无效。

    打开项目属性->配置属性->右面,平台工作集,选为v10 如下图

  9. SQL-22 统计各个部门对应员工涨幅的次数总和,给出部门编码dept_no、部门名称dept_name以及次数sum

    题目描述 统计各个部门对应员工涨幅的次数总和,给出部门编码dept_no.部门名称dept_name以及次数sumCREATE TABLE `departments` (`dept_no` char( ...

  10. oracel 日期查询

    --查出当前系统时间select SYSDATE from table; --格式转换--  TO_CHAR  把日期或数字转换为字符串 --  TO_CHAR(number, '格式')     - ...