Codeforces Testing Round #10 B. Balancer
水题,只要遍历一遍,不够平均数的,从后面的借,比平均数多的,把多余的数添加到后面即可,注意数据范围
#include <iostream>
#include <vector>
#include <cmath>
using namespace std; int main(){
int n;
cin >> n;
vector<long long> a(n);
long long sum = ;
for(int i = ; i < n; ++ i){
cin >>a[i];
sum +=a[i];
}
sum/=n;
long long cnt = ;
for(int i = ; i < n-; ++ i){
a[i+] +=a[i]-sum;
cnt+=abs(a[i]-sum);
}
cout<<cnt<<endl;
}
Codeforces Testing Round #10 B. Balancer的更多相关文章
- Codeforces Testing Round #10 A. Forgotten Episode
水题,注意数据范围 #include <iostream> using namespace std; int main(){ long long n,a; cin >> n; ...
- Codeforces Beta Round #10 D. LCIS
题目链接: http://www.codeforces.com/contest/10/problem/D D. LCIS time limit per test:1 secondmemory limi ...
- Codeforces Beta Round #10 D. LCIS 动态规划
D. LCIS 题目连接: http://www.codeforces.com/contest/10/problem/D Description This problem differs from o ...
- Codeforces Beta Round #10 C. Digital Root 数学
C. Digital Root 题目连接: http://www.codeforces.com/contest/10/problem/C Description Not long ago Billy ...
- Codeforces Beta Round #10 B. Cinema Cashier 暴力
B. Cinema Cashier 题目连接: http://www.codeforces.com/contest/10/problem/B Description All cinema halls ...
- Codeforces Beta Round #10 A. Power Consumption Calculation 水题
A. Power Consumption Calculation 题目连接: http://www.codeforces.com/contest/10/problem/A Description To ...
- Codeforces Testing Round #12 C. Subsequences 树状数组维护DP
C. Subsequences Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/probl ...
- Codeforces Testing Round #12 A. Divisibility 水题
A. Divisibility Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/probl ...
- Codeforces Testing Round #12 C. Subsequences 树状数组
C. Subsequences For the given sequence with n different elements find the number of increasing s ...
随机推荐
- js 倒计时点击和当前时间
<input id="btn" type="submit" value="确定" disabled="disabled&qu ...
- 菜鸟学Linux命令:端口查看和操作命令
>>端口和进程 端口不是独立存在的,它是依附于进程的.某个进程开启,那么它对应的端口就开启了,进程关闭,则该端口也就关闭了.下次若某个进程再次开启,则相应的端口也再次开启. >> ...
- Codeforces Round #363 Fix a Tree(树 拓扑排序)
先做拓扑排序,再bfs处理 #include<cstdio> #include<iostream> #include<cstdlib> #include<cs ...
- 使用SQL语句向已有数据表添加约束
如果向存在数据的表里添加约束,有可能会出现数据不符合检查约束而造成添加约束失败. 如: 这是一个表,为身份证号添加检查约束. USE DEmo--指向当前操作的数据库 GO ALTER TABLE E ...
- Win10 开发者模式开启
使用注册表方式:建立一个注册表DWORD为1键值:HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock\AllowAllTrust ...
- 卸载Eclipse安装的插件
背景:先前安装过Java Decompiler,不知道怎么弄的eclipse出问题之后不能用了,折腾了几次都没弄好,这次准备把这个插件先卸掉再装一次,结果发现,卸也卸不掉,最终是强制删除,以下为试过的 ...
- 1:A+B Problem
总时间限制: 1000ms 内存限制: 65536kB 描述 Calculate a + b 输入 Two integer a,,b (0 ≤ a,b ≤ 10) 输出 Output a + b ...
- 四种方案解决ScrollView嵌套ListView问题(转)
以下文章转自@安卓泡面 在工作中,曾多次碰到ScrollView嵌套ListView的问题,网上的解决方法有很多种,但是杂而不全.我试过很多种方法,它们各有利弊. 在这里我将会从使用ScrollVie ...
- memset中的sizeof
记录memset中的sizeof的用法, unsigned char *buff = (unsigned char*) malloc(128 * sizeof(char)); //错误的:memset ...
- 真机测试INSTALL_FAILED_INSUFFICIENT_STORAGE 的解决方法
来源:http://blog.csdn.net/aikongmeng/article/details/9793809 INSTALL_FAILED_INSUFFICIENT_STORAGE 的解决方法 ...