1111B - Average Superhero Gang Power
刷数学题不知道为啥出来这个
算是贪心吧,先把所有的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的更多相关文章
- CF-1111B-Average Superhero Gang Power
首先,对于这题我们要知道要删除一个数使平均值最大一定是删除最小的数,然后我们假设删除操作执行了i次,也就是删除最小的i个数.在已知删除操作次数之后求增加操作的次数就容易了,当然是m - i和k * ( ...
- codeforces contest 1111
A. Superhero Transformation 题意: 元音和元音,辅音和辅音字母之间可以互相转换,问两个字符串是否想同: 题解:直接判断即可: #include<bits/stdc++ ...
- CF-1111 (2019/2/7 补)
CF-1111 题目链接 A. Superhero Transformation tags : strings #include <bits/stdc++.h> using namespa ...
- Daily record-August
August11. A guide dog can guide a blind person. 导盲犬能给盲人引路.2. A guide dog is a dog especially trained ...
- AVAudioFoundation(4):音视频录制
本文转自:AVAudioFoundation(4):音视频录制 | www.samirchen.com 本文主要内容来自 AVFoundation Programming Guide. 采集设备的音视 ...
- [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 ...
- Display controller
Field of the Invention The present invention relates to a display controller. Background to the inve ...
- Java泛型(6):extends和super关键字
(1) <T extends A> 因为擦除移除了类型信息,而无界的泛型参数调用的方法只等同于Object.但是我们可以限定这个泛型参数为某个类型A的子集,这样泛型参数声明的引用就可以用类 ...
- training 2
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.136 Average Precision (AP) @[ IoU ...
随机推荐
- python ctrl+c
#!/usr/bin/env pythonimport signalimport sysimport osdef signal_handler(signal, frame): print('You p ...
- laravel中对模型和路由做缓存,提高性能
模型缓存命令: php think optimize:schema 路由缓存命令: php think optimize:route
- MAVEN 创建 JAR项目
从Maven模板创建一个项目 在终端或命令提示(windows)中,浏览到要创建JAVA项目的文件夹下 键入如下命令: mvn archetype:generate -DgroupId={projec ...
- isScroll 插件在iPhone 5s 和以上版本
才加入这个移动项目组三天,解决一个同事(请假),解决一个切换头部tab 选型时,下拉数据,再次切换到另外一个选项时,出现滚动条距离顶部有些距离,当频繁操作会出现距离顶部距离加大问题(第二天衍生出其他b ...
- UVa 10795 - A Different Task 对称, 中间状态, 数位DP 难度: 3
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- Spring Boot + Druid 监控数据库(三)
Druid可以做什么? 1) 可以监控数据库访问性能,Druid内置提供了一个功能强大的StatFilter插件,能够详细统计SQL的执行性能,这对于线上分析数据库访问性能有帮助. 2) 替换DBC ...
- angular4-常用指令
ngIf 指令(它与 AngularJS 1.x 中的 ng-if 指令的功能是等价) <div *ngIf="condition">...</div> n ...
- VBA续嘘嘘——宏技巧集绵
什么是VBA?它有什么作用? A.实现Excel中没有实现的功能. B.提高运行速度. C.编写自定义函数. D.实现自动化功能. E.通过插入窗体做小型管理软件. VBA在哪里存放的?怎么运行? A ...
- Cracking The Coding Interview 1.2
//原文: // // Write code to reverse a C-Style String. (C-String means that "abcd" is represe ...
- java泛型讲解
原文: https://blog.csdn.net/briblue/article/details/76736356 泛型,一个孤独的守门者. 大家可能会有疑问,我为什么叫做泛型是一个守门者.这其实是 ...