题意:
n个人围成一圈,每个人都有一些硬币,,每个人只能给左右相邻的人硬币,问最少交换几个硬币,使每个人硬币一样多;
//没用随机选择算法也可以过
//本题其实就是求各个点到中位数的和
/*
Accepted 16 sec ago 随机选择算法,时间复杂度n
Accepted 1 min ago 排序,时间复杂度n*logn
*/
#include<cmath>
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=1000000+10;
long long a[maxn],c[ma