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 ...
随机推荐
- php文件上传进度条例子
<?php session_start(); ?> <!DOCTYPE html> <html lang="zh-CN"> <head&g ...
- Mybatis 字符绑定
http://blog.csdn.net/softwarehe/article/details/8889206
- Java代码实现excel数据导入到Oracle
1.首先需要两个jar包jxl.jar,ojdbc.jar(注意版本,版本不合适会报版本错误)2.代码: Java代码 import java.io.File; import java.io.Fi ...
- [LeetCode] Binary Tree Zigzag Level Order Traversal
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to ...
- 数据结构之图 Part3 – 2 遍历
BFS using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ...
- php获取文件夹下面的文件列表和文件夹列表
function getDir($dir) { $dirArray[] = NULL; if (false != ($handle = opendir( $dir ))) { $i=0; while ...
- Sonar规则学习笔记
1. A catch statement should never catch throwable since it includes errors. 在catch里永远不要抛出throwable. ...
- sidt十六进制代码
00121453 0F010D 40441200 sidt fword ptr ds:[gliu]0012145A 0F014D B0 sidt fword ptr ss:[ebp-0x50]0012 ...
- Excel动态合并行、合并列
背景: 在北京工作的时候,又一次同事问了我这样一个问题,说我要把从数据库获取到的数据直接通过NPOI进行导出,但是我对导出的格式要特殊的要求,如图: 冥思苦想,最终顺利帮同事解决问题,虽然有点瑕疵,但 ...
- bzoj专题训练
//http://blog.csdn.net/PoPoQQQ/article/category/2542243