首先,对于这题我们要知道要删除一个数使平均值最大一定是删除最小的数,然后我们假设删除操作执行了i次,也就是删除最小的i个数。在已知删除操作次数之后求增加操作的次数就容易了,当然是m - i和k * (n - i)中比较小的数啦。用一个ans变量记录结果,遍历i,更新ans,得到最终的ans。

B - Average Superhero Gang Power GNU C++11 Accepted 46 ms 400 KB
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
const int MAXN = 1e5 + ;
int arr[MAXN];
double ans;
int main() {
int n, k, m;
scanf("%d%d%d", &n, &k, &m);
LL sum = ;
for (int i = ; i <= n; i++) {
scanf("%d", &arr[i]);
sum += arr[i];
}
sort(arr + , arr + + n);
for (int i = ; i < n && i <= m; i++) {
sum -= arr[i];
// min和max函数要求两个参数数据类型相同,k * (n - i)可能爆int,所以两边都转成LL;
ans = max(ans, (sum + min(1LL * m - i, 1LL * k * (n - i))) * 1.0 / (n - i));
}
printf("%.8lf", ans);
return ;
}

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

  1. 1111B - Average Superhero Gang Power

    刷数学题不知道为啥出来这个 算是贪心吧,先把所有的power加起来,然后sort一遍,每次删掉最小的那个数,记录一个max,平均值ave如果比max大,就替换,一定要小心m的值可能会比n小,意味着不一 ...

  2. CF 1005C Summarize to the Power of Two 【hash/STL-map】

    A sequence a1,a2,-,an is called good if, for each element ai, there exists an element aj (i≠j) such ...

  3. codeforces contest 1111

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

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

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

  5. python3 rrdtool 使用

    源自 python自动化运维:技术与最佳实践 并做略微修改 安装 yum install python-rrdtoolyum install rrdtool-devel #因为采集用了psutil模块 ...

  6. Daily record-August

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

  7. Python与rrdtool的结合模块

    rrdtool(round robin database)工具为环状数据库的存储格式,round robin是一种处理定量数据以及当前元素指针的技术.rrdtool主要用来跟踪对象的变化情况,生成这些 ...

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

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

  9. [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 ...

随机推荐

  1. Druid数据库连接池获取连接阻塞(转载)

    一. 背景        17年公司有个项目组在南京做项目的时候,开发框架用的是spring boot ,数据库连接池用的是druid,但老是遇到socket read timeout的错误,不得已放 ...

  2. Java之线程通信的方法

    /** * 线程通信的例子:使用两个线程打印 1-100.线程1, 线程2 交替打印 * * 涉及到的三个方法: * wait():一旦执行此方法,当前线程就进入阻塞状态,并释放同步监视器. * no ...

  3. polyA|ribo-minus|differentiated cell|Genetic heterogeneity

    转录组 测量单cell,可以认为是一种细胞.细胞株也认为来自同一个细胞. 使用两种方法,找mRNA(polyA)及rmRNA(ribo-minus),然后取交集. 转录组受实验影响,比如小片段没得到. ...

  4. MySQL--OPTIMIZE TABLE碎片整理

    参考:http://blog.51yip.com/mysql/1222.html BLOB和TEXT值会引起一些性能问题,特别是在执行了大量的删除操作时.删除操作会在数据表中留下很大的空洞,以后填入这 ...

  5. MySQL--SHOW TABLE STATUS命令

    show table status 获取表的信息 来自:http://blog.csdn.net/java2000_wl/article/details/7935035

  6. F - No Link, Cut Tree! Gym - 101484F

    Marge is already preparing for Christmas and bought a beautiful tree, decorated with shiny ornaments ...

  7. 第04项目:淘淘商城(SpringMVC+Spring+Mybatis)【第十一天】(购物车+订单)

    https://pan.baidu.com/s/1bptYGAb#list/path=%2F&parentPath=%2Fsharelink389619878-229862621083040 ...

  8. SoapUI+excel接口自动化测试简述

    1.自动化测试工具介绍 由于系统前后端分离,所以接口测试势在必行,在接触了几天接口测试框架,包括postman.httpclient.loadrunner.soapUI等,下面具体讲讲最终决定使用so ...

  9. 分层结构与MVC模式

    一.分层结构1.所谓分层结构.把不同的功能代码封装成类,把相同功能的类封装在一个个的包中,也叫层.功能归类如下:实体类:封装数据,是数据的载体,在层与层之间进行传递,数据也就传递了.比如说要传递学生信 ...

  10. 研究NLP100篇必读的论文---已整理可直接下载

    100篇必读的NLP论文 100 Must-Read NLP 自己汇总的论文集,已更新 链接:https://pan.baidu.com/s/16k2s2HYfrKHLBS5lxZIkuw 提取码:x ...