题意:
n 个人玩游戏,每轮游戏都有n-1 个玩家和1个主持,然后给出,每个人都想当几次玩家,问至少要办几轮比赛才可以满足每个人的需
要?
输入:
3 3 2 2
4 2 2 2 2输出:
4
3
分析:
要尽量少的办比赛,因此上界就是要求当玩家的最大需求+1,在满足这个前提下,将所有需求加和,除以玩家的数量,如果除不尽则
向上取整。之后取最大值就行。
代码:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
long long int x,sum=0,maxn=0;
cin >>n;
for(int i=0;i<n;i++)
{
cin >>x;
sum+=x;
maxn=max(maxn,x);
}
if(sum%(n-1)==0)
cout <<max(maxn,sum/(n-1))<<endl;
else
cout <<max(maxn,sum/(n-1)+1)<<endl;
return 0;
}