CodeForces 609C Load Balancing
先算出目标状态,然后拿当前状态与目标状态对比,即可算出答案
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std; const int maxn=+;
int a[maxn];
int b[maxn]; int main()
{
int n;
scanf("%d",&n);
for(int i=;i<=n;i++) scanf("%d",&a[i]); sort(a+,a++n);
int sum=;
for(int i=;i<=n;i++) sum=sum+a[i]; int ave=sum/n;
for(int i=;i<=n;i++) b[i]=ave; int MOD=sum%n;
for(int i=n;i>=n-MOD+;i--) b[i]++; // for(int i=1;i<=n;i++) printf("%d ",b[i]);
int ans=;
for(int i=;i<=n;i++)
ans=ans+max(,a[i]-b[i]); printf("%d\n",ans);
return ;
}
CodeForces 609C Load Balancing的更多相关文章
- 609C Load Balancing
题意: ”平均数“的意思是:最大数和最小数之间的差值为0或1: 先求“平均”数组,再相减. #include<iostream> #include<cstdlib> #incl ...
- Codeforces Educational Codeforces Round 3 C. Load Balancing 贪心
C. Load Balancing 题目连接: http://www.codeforces.com/contest/609/problem/C Description In the school co ...
- CF# Educational Codeforces Round 3 C. Load Balancing
C. Load Balancing time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- Educational Codeforces Round 3 C. Load Balancing
C. Load Balancing time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- CodeForces--609C --Load Balancing(水题)
Load Balancing Time Limit: 2000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Subm ...
- 【架构】How To Use HAProxy to Set Up MySQL Load Balancing
How To Use HAProxy to Set Up MySQL Load Balancing Dec 2, 2013 MySQL, Scaling, Server Optimization U ...
- UVA 12904 Load Balancing 暴力
Load Balancing Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/vi ...
- Load Balancing 折半枚举大法好啊
Load Balancing 给出每个学生的学分. 将学生按学分分成四组,使得sigma (sumi-n/4)最小. 算法: 折半枚举 #include <iostrea ...
- [zz] pgpool-II load balancing from FAQ
It seems my pgpool-II does not do load balancing. Why? First of all, pgpool-II' load balancing is &q ...
随机推荐
- iOS 导航栏去阴影
if ([[[UIDevicecurrentDevice] systemVersion] floatValue] >= 6.0) { // 首先要判断版本号,否则在iOS 6 以下的版本会闪退 ...
- 缩放系列(三):一个可以手势缩放、拖拽、旋转的layout
弄了一个下午,终于搞出来了,PowerfulLayout 下面是一个功能强大的改造的例子: 可以实现以下需求: 1.两个手指进行缩放布局 2.所有子控件也随着缩放, 3.子控件该有的功能不能丢失(像b ...
- 改良UIScrollView滚动视图
#define HEIGHT self.view.frame.size.height #define WIDTH self.view.frame.size.width @interface V ...
- selenium2.0集成测试案例
webDriver模拟点击对web工程测试还是挺方便的. package suite; import java.util.concurrent.TimeUnit; import org.junit.A ...
- UITableView的子控件高度不确定处理
比如,tableView的tableFootView的控件数量是根据网络请求的数据而定的.那么tableView并不能准确的设置其contentSize.处理方法: 在tableFootView的类中 ...
- 使用VS2013编译webkit
环境: win7_x64.VS2013 开始: 一.下载webkit 从网站"https://github.com/WebKit/webkit"下载webkit,我下载的版本最后的 ...
- js 获取当前点击的标签
- [Eclispe] NDK内建include路径修改
[Eclispe] NDK内建include路径修改 编辑 jni/android.mk 中 LOCAL_C_INCLUDES 变量后,该变量值将被列入项目属性的内建include头文件包含路径,无法 ...
- 在win7/8/10鼠标右键添加“管理员取得所有权”
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\*\Shell\TakeAuthority]"icon"=" ...
- CodeForces--TechnoCup--2016.10.15--ProblemB--Bill Total Value(字符串处理)
Bill Total Value time limit per test 1 second memory limit per test 256 megabytes input standard inp ...