博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
349B - C. Mafia
阅读量:7112 次
发布时间:2019-06-28

本文共 2039 字,大约阅读时间需要 6 分钟。

C - Mafia
Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u
Submit 

Description

One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number of rounds of the "Mafia" game they need to play to let each person play at least as many rounds as they want?

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 airounds.

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

Input
3 3 2 2
Output
4
Input
4 2 2 2 2
Output
3

Hint

You don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game).

/*题意:有n个小朋友玩游戏,这个游戏每轮必须有一个人坐庄(不能玩游戏),其他人参与游戏,每个小朋友都想当ai次玩游戏的人,问    至少多少轮游戏才能满足要求初步思路:二分,二分的条件就是将所有的小朋友的坐庄的次数和玩游戏的次数和总共需要坐庄的次数比较#错误:INF开小了*/#include 
#define INF 1e13using namespace std;long long a[100005];long long maxn=-1;int n;int main(){ // freopen("in.txt","r",stdin); scanf("%d",&n); for(int i=0;i
>a[i]; maxn=max(maxn,a[i]); } long long l=maxn,r=INF,mid,res,ans=-1; while(l<=r){ mid=(l+r)>>1; res=0; for(int i=0;i
=mid){ ans=mid; r=mid-1; }else{ l=mid+1; } } cout<
<

 

转载于:https://www.cnblogs.com/wuwangchuxin0924/p/6575056.html

你可能感兴趣的文章
RDIFramework.NET ━ .NET快速信息化系统开发框架 V3.2->Web版本模块管理界面新增模块排序功能...
查看>>
ajax与算法,sql的group处理
查看>>
《C#高级编程》笔记系列--点滴记录(持续更新中……)
查看>>
采用泳道图工具跟踪项目进度或者问题解决进度
查看>>
sql server 2008学习1–系统数据库
查看>>
找零钱的两种方法
查看>>
DM642图像处理程序的主要结构
查看>>
从微软的DBML文件中我们能学到什么(它告诉了我们什么是微软的重中之重)~三 分部类是否破坏了单一职责...
查看>>
redis的主从配置 扩容
查看>>
HDU1004 Let the Balloon Rise
查看>>
jquery 校验中国身份证号码
查看>>
PicPopupWindow的使用
查看>>
Java同样的汉字在服务器和本地的电脑上URLencode 出来的结果不一致
查看>>
node-webkit学习(4)Native UI API 之window
查看>>
SQL Server 2005 中的分区表和索引
查看>>
以最简单的登录为例,诠释JS面向对象的简单实例
查看>>
value toDF is not a member of org.apache.spark.rdd.RDD
查看>>
活动安排问题--贪心算法
查看>>
ZOJ1070 Bode Plot
查看>>
[LeetCode] Graph Valid Tree
查看>>