【链接】 我是链接,点我呀:)

【题意】

每轮游戏都要有一个人当裁判,其余n-1个人当玩家
给出每个人想当玩家的次数ai
请你求出所需要最少的玩游戏的轮数
使得每个人都能满足他们当玩家的要求.

【题解】

```cpp
/*
* 如果有x轮的话
* 理论上每个人都能玩x次
* 但是必须有x人当supervisor
* x次的话,每个人能当supervisor的次数为x-a[i]
* n*x-∑a[i]就是所有人除去必须的能打supervisor的次数
* 如果n*x-∑a[i] >= x 那么就ok
* (n-1)*x-∑a[i]>=0就好
*x>=∑a[i] / (n-1)
*要注意x需要大于等于max{a[i]}
*/
```

【代码】

import java.io.*;
import java.util.*; public class Main { static InputReader in;
static PrintWriter out; public static void main(String[] args) throws IOException{
//InputStream ins = new FileInputStream("E:\\rush.txt");
InputStream ins = System.in;
in = new InputReader(ins);
out = new PrintWriter(System.out);
//code start from here
new Task().solve(in, out);
out.close();
} static int N = 100000;
static class Task{
/*
* 如果有x轮的话
* 理论上每个人都能玩x次
* 但是必须有x人当supervisor
* x次的话,每个人能当supervisor的次数为x-a[i]
* n*x-∑a[i]就是所有人除去必须的能打supervisor的次数
* 如果n*x-∑a[i] >= x 那么就ok
* (n-1)*x-∑a[i]>=0就好
*x>=∑a[i] / (n-1)
*/
int n;
int a[]; public void solve(InputReader in,PrintWriter out) {
n = in.nextInt();
a = new int[N+10];
int ma = 0;
for (int i = 1;i <= n;i++) {
a[i] = in.nextInt();
ma = Math.max(ma,a[i]);
}
long ans;
long sum = 0;
for (int i = 1;i <= n;i++) sum += a[i];
if (sum%(n-1)==0) {
ans = sum/(n-1);
}else {
ans = sum/(n-1) + 1;
}
ans = Math.max(ans, ma);
out.println(ans);
}
} static class InputReader{
public BufferedReader br;
public StringTokenizer tokenizer; public InputReader(InputStream ins) {
br = new BufferedReader(new InputStreamReader(ins));
tokenizer = null;
} public String next(){
while (tokenizer==null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(br.readLine());
}catch(IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
} public int nextInt() {
return Integer.parseInt(next());
}
}
}

【Codeforces 348A】Mafia的更多相关文章

  1. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  2. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  3. 【codeforces 707C】Pythagorean Triples

    [题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...

  4. 【codeforces 709D】Recover the String

    [题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...

  5. 【codeforces 709B】Checkpoints

    [题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...

  6. 【codeforces 709C】Letters Cyclic Shift

    [题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...

  7. 【Codeforces 429D】 Tricky Function

    [题目链接] http://codeforces.com/problemset/problem/429/D [算法] 令Si = A1 + A2 + ... + Ai(A的前缀和) 则g(i,j) = ...

  8. 【Codeforces 670C】 Cinema

    [题目链接] http://codeforces.com/contest/670/problem/C [算法] 离散化 [代码] #include<bits/stdc++.h> using ...

  9. 【codeforces 515D】Drazil and Tiles

    [题目链接]:http://codeforces.com/contest/515/problem/D [题意] 给你一个n*m的格子; 然后让你用1*2的长方形去填格子的空缺; 如果有填满的方案且方案 ...

随机推荐

  1. javascript BOM基本知识

    1.BOM(Bowser Object Model浏览器对象模型) 浏览器创建的对象通常称作文档(Document)对象,它是浏览器使用的众多对象的一部分,浏览器操作的对象结合起来称作浏览器对象模型( ...

  2. 大神给你分析HTTPS和HTTP的区别(转)

    http://www.php100.com/html/it/biancheng/2015/0209/8582.html 今天在做雅虎的时候,发现用第三方工具截取不到客户端与服务端的通讯,以前重来没碰到 ...

  3. bzoj 1604: [Usaco2008 Open]Cow Neighborhoods 奶牛的邻居【切比雪夫距离+并查集+multiset】

    参考:http://hzwer.com/4361.html 坐标开long long,inf开大点 先曼哈顿转切比雪夫(x+y,x-y),距离就变成了max(x',y'): 先按x排序,维护两个指针, ...

  4. 【题解】自行车比赛 [AHOI2016] [P2777]

    [题解]自行车比赛 \([AHOI2016]\) \([P2777]\) 逼自己每天一道模拟题 传送门:自行车比赛 \([AHOI2016]\) \([P2777]\) [题目描述] 比赛中一共有 \ ...

  5. [51nod]1678 lyk与gcd(莫比乌斯反演)

    题面 传送门 题解 和这题差不多 //minamoto #include<bits/stdc++.h> #define R register #define pb push_back #d ...

  6. Spring boot 分环境部署

    一.如果配置文件为:application.properties时 1.application.properties用于填些公共文件 以下为不同环境的配置文件需要单独配置 application-de ...

  7. 微信小程序资源

    1.http://blog.csdn.net/wyx100/article/details/52667518 2.http://mp.weixin.qq.com/s?__biz=MzIyMDM2Mjg ...

  8. Windows8.1查看已连接无线WIFI密码

    Windows8.1操作系统下查看已连接无线wifi密码操作步骤如下: 1.右键任务栏中的无线图标,在弹出的菜单中选择"打开网络和共享中心": 2.在网络和共享中心界面中点击&qu ...

  9. uiautomatorviewer详解

    一,uiautomatorviewer是什么? Android 4.1发布的,uiautomator是用来做UI测试的.也就是普通的手工测试,点击每个控件元素 看看输出的结果是否符合预期.比如 登陆界 ...

  10. 待销售分拣单App数据推送

    管理待分拣商品的App的显示操作