当前位置:网站首页>uva11300
uva11300
2022-06-21 12:28:00 【小刀刺大熊】
#include <iostream>
#include <istream>
#include <sstream>
#include <vector>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cmath>
#include <cctype>
#include <string>
#include <cstdio>
#include <iomanip>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <functional>
#include <iterator>
using namespace std;
const int maxn = 1000007;
long long int input[maxn],c[maxn],n;
int main()
{
static auto speedup = [](){
ios::sync_with_stdio(false);cin.tie(nullptr);return nullptr;}();
while(cin >> n){
long long int tot = 0;
for(int i = 0;i < n;i++){
cin >> input[i];
tot += input[i];
}
long long int m = tot / n;
c[0] = 0;
for(int i = 1;i < n;i++){
c[i] = c[i-1] + input[i] - m;
}
sort(c,c+n);
long long int mid = c[n/2],ans = 0;
for(int i = 0;i < n;i++ ){
ans += abs(mid - c[i]);
}
cout << ans << endl;
}
return 0;
}
边栏推荐
- WPF uses Maui's self drawing logic
- 在数字时代实现IT敏捷性的12个技巧
- Generalized Focal Loss: Learning Qualified and Distributed Bounding Boxes for Dense Object Detection
- Graveyard
- Educoder 表格标签—表格高级样式的设置
- CPU、MPU、MCU、SoC、MCM介绍
- PingCAP 入选 2022 Gartner 云数据库“客户之声”,获评“卓越表现者”最高分
- typescript localStorage 封装
- SQL左连接的关联条件问题
- STM32笔记之 PWM(脉宽调制)
猜你喜欢

Six relationships of UML - system learning IV

Sdcc compiler + vscode to develop 8-bit microcontroller

Vs code + GDB download and debugging of STM32 development

Educoder Web练习题---文本层次语义元素

Educoder 表格标签-表格基本结构

Generalized Focal Loss: Learning Qualified and Distributed Bounding Boxes for Dense Object Detection

matplotlib 画图 Tips

i. MX - rt1052 boot start

CPU、MPU、MCU、SoC、MCM介绍

青龙面板XDD-PLUS登录提示“当前登录环境异常,为保障您的账号安全,暂时无法登录。建议将两个设备连接同一网络或WIFI后重新扫码”解决方法。
随机推荐
Redis personal summary concise version
Educoder Web练习题---创建文本区域
路由器Telnet及ACL配置
[100 unity stepping pit knowledge points] | draw cube dotted line and sphere dotted line (gizmos auxiliary wireframe) in the editor
Educoder 表格标签—表格高级样式的设置
安科瑞BM100系列信号隔离器的实际应用
i.MX - RT1052 脉宽调制(PWM)
STM32笔记之 SWJ(JTAG-DP和 SW-DP)
版本号命名规范
子网掩码计算
8. 结构体
STM32 notes swj (jtag-dp and sw-dp)
EasyUI-input取/赋值
i. MX - rt1052 input / output (GPIO)
Workbench常见网格划分方法讲解
[100 unity pit knowledge points] | unity uses quaternion Angleaxis random one direction
20n10-asemi medium and low voltage MOS tube 20n10
Redis bitmap
channels详细使用说明
Brief discussion on four full bonding processes of oca\uv-oca loca\sloca