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

算是贪心吧,先把所有的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. 运维相关 docker

  2. 套接字编程,建立连接connect,绑定套接字bind

    1.建立连接 int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen); 参数sockfd是由函数socket创建 ...

  3. gradle set

    gradle安装   1◆ gradle下载 http://services.gradle.org/distributions/       2◆ 配置环境 =====>D:\envs\grad ...

  4. oracle函数NVL,NVL2和NULLIF之间的区别和使用

    oracle用这么几个函数,可以帮助我们解决数据上null或0的处理 1.NVL()函数 1.1)介绍:NVL(expr1,expr2),若expr1为null, 返回expr2; 不为null,返回 ...

  5. ubuntu 双硬盘挂载 windows分区自动挂载

    sudo fdisk -l 查看硬盘情况 1:新建一个目录,例:old 2:mount  /dev/sdb1  old 3:cd old 4:ls  (就可以看到新硬盘的内容了) 取消挂载:umoun ...

  6. python小数据池,代码块知识

    一.什么是代码块? 根据官网提示我们可以获知: A Python program is constructed from code blocks. A block is a piece of Pyth ...

  7. bzoj3277

    题解: 后缀自动机 然后抄了一发题解 可以看看这个博客:http://blog.csdn.net/clover_hxy/article/details/53861268 代码: #include< ...

  8. Linux查看某个进程的磁盘IO读写情况 pidstat

    一.现象 1)钉钉告警不断,告警如下CPU使用达到100% 普罗米修斯监控 2)查看数据库,没有发现比平时同一时段,业务量的增加.但是,数据库显示latch free等告警,验证了CPU使用过高导致. ...

  9. json 2017-04-21 10 17

    jo := SO(); jo.S['tttt'] := 'tttt'; TbSendedTidJson['jo'] := jo; ja := TbSendedTidJson['jo'];//取出来后, ...

  10. flask项目结构(一)mariadb

    简介: 本文主要是根据自己所学,创建一个flask项目,使用sqlalchemy,alembic,mariadb,bootstrap,APScheduler,selenium,request…………技 ...