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 ...
随机推荐
- 针对unicode对象---检测字符串是否只由数字组成
- net core 上传并使用EPPlus导入Excel文件
1. cshtml页面 form <form id="form" method="post" action="/SaveValueBatch& ...
- 窗体应用程序防腾讯QQ源码
窗体应用程序防腾讯QQ源码 using System; using System.Collections.Generic; using System.ComponentModel; using Sys ...
- html5手机web app <input type="file" > 只调用图库,禁止调用摄像头?
<input type="file" accept="image/*"><input type="file" accept ...
- oracle如何创建表的自增ID(通过触发器)
Oracle中创建表的自增ID(通过触发器),序列的自增ID和触发器的自增ID的区别 1.新增数据(序列) --创建示例表 -- create table Student( stuId ) not n ...
- Win10系列:JavaScript动画4
上面介绍的动画效果是通过Windows动画库创建的,这里的旋转动画是通过设置页面元素的style对象的相关属性来创建,此动画的效果是将界面元素沿着指定的方向进行旋转.下面介绍style对象的几个常用属 ...
- Android 平台架构
Android 平台主要组件如下 Linux 内核 Android 平台的基础是 Linux 内核.例如,Android Runtime (ART) 依靠 Linux 内核来执行底层功能,例如线程和低 ...
- Vue + Element UI 实现权限管理系统(动态加载菜单)
动态加载菜单 之前我们的导航树都是写死在页面里的,而实际应用中是需要从后台服务器获取菜单数据之后动态生成的. 我们在这里就用上一篇准备好的数据格式Mock出模拟数据,然后动态生成我们的导航菜单. 接口 ...
- django搭建博客
https://andrew-liu.gitbooks.io/django-blog/content/index.html
- RabbitMQ 设置队列的过期时间
设置队列的过期时间非常简单,在声明队列时,设置x-expires参数即可.当队列的生存周期超时后,RabbitMQ server会自动将该队列删除. 代码如下: channel.QueueDeclar ...