UVA11300 Sqreading the Wealth
来源:互联网 发布:购物网络平台有哪些 编辑:程序博客网 时间:2024/05/17 03:51
思路:大白原题,看书上的解释得很好
#include <cstdio>#include <queue>#include <cstring>#include <iostream>#include <cstdlib>#include <algorithm>#include <vector>#include <map>#include <string>#include <set>#include <ctime>#include <cmath>#include <cctype>using namespace std;#define maxn 1000000+10#define LL long longLL A[maxn],C[maxn],tot,M;int cas=1,T;int main(){int n;while (scanf("%d",&n)!=EOF){tot=0;for (int i = 1;i<=n;i++){ scanf("%lld",&A[i]);tot+=A[i];}M=tot/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],ans=0;for (int i = 0;i<n;i++)ans+=abs(x1-C[i]);printf("%lld\n",ans);}//freopen("in","r",stdin);//scanf("%d",&T);//printf("time=%.3lf",(double)clock()/CLOCKS_PER_SEC);return 0;}
0 0
- UVA11300 Sqreading the Wealth
- UVA11300:Spreading the Wealth
- UVA11300 Spreading the Wealth
- uva11300 Spreading the Wealth
- Uva11300 - Spreading the Wealth
- UVa11300 - Spreading the Wealth
- Uva11300 - Spreading the Wealth
- uva11300 Spreading the Wealth
- UVA11300:Spreading the Wealth
- UVA11300:Spreading the Wealth
- uva11300 - Spreading the Wealth (中位数)
- uva11300 - Spreading the Wealth(分金币)
- UVa11300 - Spreading the Wealth (分金币)
- UVA11300 Spreading the Wealth (数学推导+中位数)
- [UVA11300][智商题]Spreading the Wealth
- UVa11300 Spreading the Wealth(数学问题)
- UVA11300——Spreading the Wealth (贪心+建模)
- 11300 - Spreading the Wealth
- XMPP的简单了解及使用(3)
- Codeforces Round #344 (Div. 2) C. Report【水题】
- 【考试】70天复习一次通过信息系统项目管理师考试经验和心得
- Git fetch和git pull的区别
- 进程间通信Messenger
- UVA11300 Sqreading the Wealth
- 关于我的android软件--贵金属
- android 贵金属 2.1
- [OJ ] Majority Element II
- android软件-电视指南
- android 贵金属 2.2
- android-电视指南 1.1
- 贵金属2.3
- 贵金属2.4