A. Mafia
Time Limit: 20 Sec Memory Limit: 256 MB
题目连接
http://codeforces.com/contest/348/problem/A
Description
Input
The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play.
Output
In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
Sample Input
3
3 2 2
Sample Output
4
HINT
题意
有n个人,在玩一个游戏,游戏表示每局都必须有个管理员参加
告诉你,每个人想当多少局玩家,然后让你求,最少多少局游戏,才能满足题意!
题解:
贪心就好了,类似厨师煮饼那道题一样
max(max_num,sum/(n-1));
代码:
//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
#define maxn 200001
#define mod 1000000007
#define eps 1e-9
int Num;
char CH[];
//const int inf=0x7fffffff; //нчоч╢С
const int inf=0x3f3f3f3f;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
inline void P(int x)
{
Num=;if(!x){putchar('');puts("");return;}
while(x>)CH[++Num]=x%,x/=;
while(Num)putchar(CH[Num--]+);
puts("");
}
//************************************************************************************** ll a[maxn];
ll sum=;
ll mx=;
int main()
{
int n=read();
for(int i=;i<=n;i++)
a[i]=read(),sum+=a[i],mx=max(a[i],mx);
n=n-;
ll ans;
ans=sum/n;
if(sum%n!=)
ans++;
cout<<max(mx,ans)<<endl;
}