Mafia
来源:互联网 发布:暗黑黎明官网老虎端口 编辑:程序博客网 时间:2024/05/29 23:24
One day n friends gathered together to play “Mafia”. During each round of the game some player must be the supervisor and other n - 1 people 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 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.
Example
Input
3
3 2 2
Output
4
Input
4
2 2 2 2
Output
3
一天,n个朋友聚在一起玩“黑手党”。在每一轮比赛中,一些玩家必须是裁判和其他n - 1人参加比赛。对于每个人,我们知道他想成为一名玩家的次数,而不是裁判:要让每个人至少玩多少个回合,他们需要玩多少轮“黑手党”游戏?
因为每个人都要最少玩他们他们想玩的次数,所以游戏的轮数应该大于等于想玩次数最多的次数.因为每一轮都有一个人要当裁判,所以裁判的人数大于等于游戏轮数.
#include <stdio.h>long long a[100005];int main(){ long long max = 0,n,x,y,z,t; //有多少个人玩 scanf("%lld",&n); //每个人想玩的次数 for(x=0;x<n;x++) { scanf("%lld",&a[x]); if(a[x]>max)//找出最大次数 ,当成游戏的轮数 { max = a[x]; } } long long num = 0; //找出有max轮游戏的时候能当裁判的人数 for(x=0;x<n;x++) { num += max - a[x];//max-a[x]为a[x]能当裁判的次数 } long long num1; if(num<max)//如果能当裁判的人数小于想玩的最多次数,则轮数增加 { num1 = max - num;//还差多少此裁判才能完成 //每当游戏次数即max加1,则能当裁判的人数增加n-1个 //游戏次数增加的次数等于 相差的次数/(n-1) if(num1%(n-1)) { max += num1/(n-1) + 1; } else { max += num1/(n-1); } } printf("%lld\n",max); return 0;}
- Mafia
- Mafia
- Mafia
- Mafia's life
- CodeForces 349 C. Mafia
- CF 348A Mafia
- lightoj 1219 - Mafia 贪心
- codeforces202A. Mafia【二分】
- 【CodeForces】[348A]Mafia
- CodeForces 348A Mafia
- codeforces 348A Mafia
- Codeforces 349C - Mafia
- bzoj1339: [Baltic2008]Mafia
- A. Mafia----二分答案
- BZOJ1163: [Baltic2008]Mafia
- 黑帮网游 online mafia games
- 【CF】CodeForces 348A Mafia
- N - Mafia Codeforces 348A
- C++:学生考勤系统
- TensorFlow文本摘要生成
- HDU 2037 今年暑假不AC(贪心 最多不相交区间)
- C++:足球联赛积分系统
- 10部经典的官场小说
- Mafia
- 徐登沿的第九个程序(计算并输出两个整数的最大值)
- 收银台界面 计算器html+css 块水平垂直居中
- 关于Qcow2特性的一些总结
- Kafka设计解析(一)- Kafka背景及架构介绍
- 面向对象的一个基本理解
- 解决Android studio安装后首次新建工程gradle下载失败的问题
- 漫步最优化四十四——基本拟牛顿法
- 使用TuShare下载历史逐笔成交数据并生成1分钟线