/* * Mafia.cpp * * Created on: 2013-10-12 * Author: wangzhu *//** * 每个人都想玩若干场,求至少需要玩几场才可以满足大家的需求。 * 结果必然在某个人想玩的次数nmax(此人想玩的是最多的)与所有人想玩的次数和sum之间, * 故二分,left = nmax,right = sum, * 只需要需要玩的次数 * (总人数-1) >= 大家想玩的次数和即可 * */#include#include using namespace std;#define LL long long#define NMAX 100010int arr[NMAX];LL binary(int n, int nmax, LL sum) { LL mid = -1, left = nmax, right = sum; while (left <= right) { mid = left + (right - left) / 2; if (sum <= (mid * n)) { right = mid - 1; } else { left = mid + 1; } } return left;}int main() { freopen("data.in", "r", stdin); int n, nmax; LL sum; while(~scanf("%d",&n)) { nmax = -1; sum = 0; for(int i = 0;i < n;i++) { scanf("%d",arr + i); if(nmax < arr[i]) { nmax = arr[i]; } sum += arr[i]; } printf("%I64d\n",binary(n - 1,nmax,sum)); } return 0;}