uva11300
来源:互联网 发布:mac l2tp服务器未响应 编辑:程序博客网 时间:2024/06/14 12:09
中位数问题。
#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>#define LL long long#define maxn 1000000+10using namespace std;LL a[maxn],c[maxn],M,n;int main(){ while(scanf("%lld",&n)!=EOF) { LL sum=0,cnt=0; for(int i=1; i<=n; i++) { scanf("%lld",&a[i]); sum+=a[i]; } M = sum/n; c[0]=0; for(int i=1; i<n; i++) c[i]=c[i-1]+a[i]-M; sort(c,c+n); LL x1=c[n/2]; for(int i=0; i<n; i++) cnt+=abs(x1-c[i]); printf("%lld\n",cnt); } return 0;}
0 0
- UVa11300
- uva11300
- uva11300
- UVa11300
- UVa11300
- UVa11300
- 中位数uva11300
- uva11300-中位数
- UVA11300:Spreading the Wealth
- UVA11300 Spreading the Wealth
- uva11300 Spreading the Wealth
- UVA11300分金币
- uva11300(数学)
- Uva11300 - Spreading the Wealth
- uva11300 + uvalive5809 中位数
- UVA11300 分金币
- uva11300(抽象,推导)
- UVa11300 - Spreading the Wealth
- c++读取word文件
- 利用textField的代理和手势来进行取消第一响应的事件来提高用户体验!
- 多图真相:Adobe Dreamweaver CC 2014.1来了-体验卓越PSD提取和诸多精彩云功能!
- [Leetcode]Excel Sheet Column Number
- 判断大小端模式
- uva11300
- 编程高手无捷径
- POJ2538 还能再水一点吗...
- grep 使用, 部分大小写查询多个 字符
- JAVA NIO 选择器
- sklearn学习(1) 数据集
- [Leetcode]Factorial Trailing Zeroes
- make: *** No rule to make target `all'. Stop.
- (2.2.2)Java之美[从菜鸟到高手演变]之设计模式一:创建型模式