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

算是贪心吧,先把所有的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. Linux 第一周作业

    [](http://images2017.cnblogs.com/blog/1249774/201710/1249774-20171001234038872-10d31233192.pngd

  2. 【转载三】Grafana系列教程–Grafana的配置及运行

    本篇文章,就让我们来了解下,Grafana的简单配置及运行. 详细的配置我们后面会讲,本篇文章只对其配置做一个简单了解,主要是让大家了解Grafana的配置及启动的过程及方法. 更多Grafana问题 ...

  3. Cracking The Coding Interview4.8

    //You are given a binary tree in which each node contains a value. Design an algorithm to print all ...

  4. 7 Serial Configuration 理解(二)

    *Serial Configuration Mode 串行配置模式分为:Master Serial 和 Slave Serial (如下图)两类: 两者的区别在与CCLK的输入输出方向:主动模式下为输 ...

  5. DevExpress WinForms使用教程:Ribbon性能

    [DevExpress WinForms v18.2下载] DevExpress XAF团队提供Ribbon新能改进,其中XAF Office Module的实际应用程序需要花费很长时间才能加载,导致 ...

  6. DevExpress v18.1新版亮点——CodeRush for VS篇(一)

    用户界面套包DevExpress v18.1日前正式发布,本站将以连载的形式为大家介绍各版本新增内容.本文将介绍了CodeRush for Visual Studio v18.1 的新功能,快来下载试 ...

  7. 第一个python程序--hello,world

    Hello World程序 在linux 下创建一个文件叫hello.py,并输入 print ('hello,word') 然后执行:python3 hello.py ,输出: [root@IDC- ...

  8. 设置网页icon标志

    下载一个你喜欢的icon,文件格式为ico,然后将这个文件重命名为favicon.ico,并把文件放在网站的根目录下. 一般在ie8版本以上都支持icon图标.但是在此版本一下,我们需要添加一段代码. ...

  9. Android:DELETE_FAILED_INTERNAL_ERROR Error while Installing APKs

     Android studio DELETE_FAILED_INTERNAL_ERROR Error while Installing APKs 一.报错信息 DELETE_FAILED_INTERN ...

  10. shell开源跳板机sshstack

    笔者Q:972581034 交流群:605799367.有任何疑问可与笔者或加群交流 源码地址: https://github.com/sshstack/sshstack 为什么要写shell跳板机? ...